socket.io 小記


1
2
3
4
5
6
7
8
// 只發送給當前連接中/請求中的客戶端
socket.emit('message', "this is a test");

// 發送給全部連接中的客戶端,包括自己
io.sockets.emit('message', "this is a test");

// 除自己外.發送給全部連接中的客戶端
socket.broadcast.emit('message', "this is a test");