打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Socket.io各个发送消息的含义

Socket.io各个发送消息的含义

// send to current request socket clientsocket.emit('message', "this is a test");// sending to all clients, include senderio.sockets.emit('message', "this is a test");// sending to all clients except sendersocket.broadcast.emit('message', "this is a test");// sending to all clients in 'game' room(channel) except sendersocket.broadcast.to('game').emit('message', 'nice game');// sending to all clients in 'game' room(channel), include senderio.sockets.in('game').emit('message', 'cool game');// sending to individual socketidio.sockets.socket(socketid).emit('message', 'for your eyes only');// 进入一个房间socket.join('room'); // 离开一个房间socket.leave('room');

订阅/退订事件

//前端触发订阅/退订事件socket.emit('subscribe',{"room" : "room_name"};socket.emit('unsubscribe',{"room" : "room_name"};//后台处理订阅/退订事件socket.on('subscribe', function(data) {     socket.join(data.room);})socket.on('unsubscribe', function(data) {     socket.leave(data.room);})

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Introduction | Socket.IO
移动前端系列——websocket实时互动小游戏
Realtime data with MQTT, Node.js, MQTTClient.js and Socket.IO
socket基础知识及js中的Web Sockets
通过Socket.IO与nodeJs实现即时消息推送
PHPSocket.IO知识学习整理
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服