//给除了自己以外的客户端广播消息
socket.broadcast.emit("msg",{data:"hello,everyone"});
//给所有客户端广播消息
io.sockets.emit("msg",{data:"hello,all"});
socket.on('group1', function (data) {
socket.join('group1');
});
socket.on('group2',function(data){
socket.join('group2');
});
socket.leave(data.room);
io.sockets.clients().forEach(function (socket) { //.....})
io.of('/some').on('connection', function (socket) { socket.on('test', function (data) { socket.broadcast.emit('event_name',{}); });});
var socket = io.connect('ws://103.31.201.154:5555/some')socket.on('even_name',function(data){ console.log(data);})
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |