Recall & Review
beginner
What is a WebSocket Gateway in NestJS?
A WebSocket Gateway in NestJS is a special class that handles WebSocket connections, allowing real-time communication between the server and clients.Click to reveal answer
beginner
Which decorator is used to create a WebSocket Gateway in NestJS?
The @WebSocketGateway() decorator is used to mark a class as a WebSocket Gateway in NestJS.Click to reveal answer
beginner
How do you listen for a specific WebSocket event in a NestJS Gateway?
Use the @SubscribeMessage('eventName') decorator on a method inside the Gateway class to listen for that event.Click to reveal answer
intermediate
What method signature should a message handler have in a NestJS WebSocket Gateway?
A message handler method should accept two parameters: the client socket and the data sent by the client, e.g., handleMessage(client: Socket, payload: any).
Click to reveal answer
beginner
How can you send a message back to the client from a WebSocket Gateway in NestJS?
You can use the client.emit('eventName', data) method to send a message back to the connected client.
Click to reveal answer
Which decorator marks a class as a WebSocket Gateway in NestJS?
✗ Incorrect
The @WebSocketGateway() decorator is specifically used to create WebSocket Gateways.
How do you listen for a WebSocket event named 'chat' in a NestJS Gateway?
✗ Incorrect
The @SubscribeMessage('eventName') decorator listens for WebSocket events.
What parameters does a WebSocket message handler method usually receive?
✗ Incorrect
Handlers receive the client socket and the data sent by the client.
Which method sends a message back to the client in a NestJS WebSocket Gateway?
✗ Incorrect
client.emit() sends an event with data back to the connected client.
What is the main purpose of a WebSocket Gateway in NestJS?
✗ Incorrect
WebSocket Gateways manage real-time communication using WebSockets.
Explain how to create a basic WebSocket Gateway in NestJS and listen for a message event.
Think about decorators and message handlers.
You got /5 concepts.
Describe how a NestJS WebSocket Gateway handles incoming messages and sends responses.
Focus on the flow of message handling.
You got /5 concepts.