广播时不支持回调 [英] Callbacks are not supported when broadcasting
本文介绍了广播时不支持回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这里,我遇到一个关于node.js的socket.io中回调的问题
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);
});
我面临的错误在广播时不支持回调,因此任何人都可以解决。 p>
Where i am facing error of Callbacks are not supported when broadcasting so anyone have solution of this.
推荐答案
首先,从id中获取套接字对象,您可以参考Socket.IO 1.0.x:按ID获取套接字
First, get socket object from id, which you can refer to Socket.IO 1.0.x: Get socket by id
然后用套接字对象 socket.emit('type','message',ack => {});
这篇关于广播时不支持回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文