-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
needs triageThis issue has not been looked intoThis issue has not been looked intotype: enhancement πΊ
Description
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
I use @nestjs/websocket
.
https://docs.nestjs.com/websockets/gateways
To add disconnect event handler, OnGatewayDisconnect
lifecycle hook is useful.
But this hook is not able to get disconnect reason.
Describe the solution you'd like
My code is below. (handleDisconnect
can not get disconnect reason.)
export class EventsGateway implements OnGatewayConnection<Socket> {
async handleConnection(socket: Socket) {
// add disconnect handler manually.
socket.on('disconnect', async reason => {
await this._handleDisconnect(socket, reason)
})
}
async _handleDisconnect(socket: Socket, reason: DisconnectReason) {
// handle disconnect
}
}
Expect code is below. (handleDisconnect
can get disconnect reason.)
export class EventsGateway implements OnGatewayConnection<Socket>, OnGatewayDisconnect <Socket> {
async handleConnection(socket: Socket) {
// handle connect
}
async handleDisconnect(socket: Socket, reason: DisconnectReason) {
// handle disconnect
}
}
Teachability, documentation, adoption, migration strategy
n/a
What is the motivation / use case for changing the behavior?
n/a
Metadata
Metadata
Assignees
Labels
needs triageThis issue has not been looked intoThis issue has not been looked intotype: enhancement πΊ