io.on('connect',onConnect)
socket.emit('hello',"can you hear me?",1,2,"abc");
socket.broadcast.emit("boradcast","hello friends!");
// 发送到 “game” room中除发件人以外的所有客户端
socket.to("game").emit("nice game","let't play a game");
// 发送到“game1”和/或“game2”房间中的所有客户端,发件人除外
socket.to('game1').to('game2').emit("nice game","let's play a game (too)");
io.in('game').emit('big-announcement',"the game will start soon");
// 发送到命名空间“mynamespace”中的所有客户端,包括发件人
io.of('myNamespace').emit('bigger-announcement',"the tournament will start soon");
io.of('myNamespace').to('root').emit('event',"message");
// 警告:`socket.to(socket.id).emit()` ,不会工作,因为它会发送给房间里的每个人
// 命名 `socket.id` ,但为发件人。请改用经典的“socket.emit()”。
socket.emit('question',"do you think so?",(answer)=>{
socket.compress(false).emit('uncomressed',"that's rough");
socket.binary(false).emit('what',"I hava no binaries!");
io.local.emit('hi',"my lovely babies");
io.emit('an event send to all connected clients';)