Callbacks are not supported when broadcasting

匆匆过客 提交于 2019-12-25 00:58:18

问题


Here I am facing one issue with Callbacks in socket.io with nodejs

io.sockets.to(usersocketid).emit('receivemsg', 
{'success':'1','data':message},function(deliverycb){ 
    console.log('delivery call back');
    console.log(deliverycb);
});

Where i am facing error of Callbacks are not supported when broadcasting so anyone have solution of this.


回答1:


Emit doesn't have any callback. Broadcast your data first and then log it into console.

let broadcastData = {'success':'1','data':message};
io.sockets.to(usersocketid).emit('receivemsg',broadcastData );
console.log('delivery call back');
console.log(broadcastData );


来源:https://stackoverflow.com/questions/52676171/callbacks-are-not-supported-when-broadcasting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!