大佬教程收集整理的这篇文章主要介绍了将响应发送给除发件人以外的所有客户端,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的列表 (已更新为1.0) :
// sending to sender-clIEnt only
socket.emit('message', "this is a test");
// sending to all clIEnts, include sender
io.emit('message', "this is a test");
// sending to all clIEnts except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clIEnts in 'game' room(chAnnel) except sender
socket.broadcast.to('game').emit('message', 'nice game');
// sending to all clIEnts in 'game' room(chAnnel), include sender
io.in('game').emit('message', 'cool game');
// sending to sender clIEnt, only if they are in 'game' room(chAnnel)
socket.to('game').emit('message', 'enjoy the game');
// sending to all clIEnts in namespace 'mynamespace', include sender
io.of('mynamespace').emit('message', 'gg');
// sending to indivIDual socketID
socket.broadcast.to(socketID).emit('message', 'for your eyes only');
// List socketID
for (var socketID in io.sockets.sockets) {}
OR
Object.keys(io.sockets.sockets).forEach((socketID) => {});
以上是大佬教程为你收集整理的将响应发送给除发件人以外的所有客户端全部内容,希望文章能够帮你解决将响应发送给除发件人以外的所有客户端所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。