Nest: Websocket acknowledgement

Created on 16 Nov 2017  路  4Comments  路  Source: nestjs/nest

Does onMessage support the acknowledgement callback?

Example 1:
@SubscribeMessage('events')
onEvent(client, data): WsResponse {
const event = 'events';
return { event, data };
}

Example 2:
socket.on('news', (data, callback) => {
callback(0);
});

question 馃檶

Most helpful comment

I wrote this module over nestjs, which do it under the hood so you don't need to call ack callback explicitly, you only need to return value or throw error: https://www.npmjs.com/package/nestjs-socket-handlers-with-ack . Hope it helps

All 4 comments

Hi @danapier,
By default - no, but you can do this easily using WsAdapter https://docs.nestjs.com/websockets/adapter

@danapier did you get this working somehow? I've been trying to implement the same thing myself but can't get it working.

I wrote this module over nestjs, which do it under the hood so you don't need to call ack callback explicitly, you only need to return value or throw error: https://www.npmjs.com/package/nestjs-socket-handlers-with-ack . Hope it helps

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artaommahe picture artaommahe  路  3Comments

VRspace4 picture VRspace4  路  3Comments

JulianBiermann picture JulianBiermann  路  3Comments

marshall007 picture marshall007  路  3Comments

FranciZ picture FranciZ  路  3Comments