Complete the code to create a WebSocket gateway using the correct decorator.
import { [1] } from '@nestjs/websockets'; @[1]() export class ChatGateway {}
Complete the code to specify the namespace for the gateway.
import { Gateway, WebSocketServer } from '@nestjs/websockets'; @Gateway({ namespace: '[1]' }) export class ChatGateway { @WebSocketServer() server; }
Fix the error in the gateway decorator usage.
import { Gateway } from '@nestjs/websockets'; @Gateway({ [1]: '/chat' }) export class ChatGateway {}
Fill both blanks to import and use the decorator that marks a method as a message handler.
import { Gateway, [1] } from '@nestjs/websockets'; @Gateway() export class ChatGateway { @[2]('message') handleMessage(client, payload) { // handle incoming message } }
Fill all three blanks to correctly inject the WebSocket server and emit an event.
import { Gateway, WebSocketServer, SubscribeMessage } from '@nestjs/websockets'; import { Server } from 'socket.io'; @Gateway() export class ChatGateway { @[1]() server: [2]; @SubscribeMessage('sendMessage') handleSendMessage(client, payload) { this.server.[3]('newMessage', payload); } }
