7 NÄ°SAN 2012, CUMARTESÄ°
Gönderen (Soket hariç.tüm istemciler için yanıt gönder io)
Her müşteri için bir şeyler göndermek için kullanın:
io.sockets.emit('response', data);
Müşteriler almak için, kullanın:
socket.on('cursor', function(data) {
...
});
Nasıl bir istemci sunucuya bir mesaj alırken, bir mesaj gönderme dışındaki tüm kullanıcılar için bu mesajı gönderiyorum, böylece iki birleştirebilir miyim.
socket.on('cursor', function(data) {
io.sockets.emit('response', data);
});
Etrafındaki istemci üzerinde ileti-kimliği istemci ve sonra Çek göndererek kesmek gerekiyor yoksa daha kolay bir yolu var mı?
CEVAP
11 NİSAN 2012, ÇARŞAMBA
İşte benim listesi(1.0 güncellendi):
// 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');
Bunu PaylaÅŸ:
Neden Ruby Hariç => e `kurtarmak iç...
Belirli dosyaları hariç tar dizin kabu...
Nasıl rspec'In should_raise hariç...
'metin arasındaki fark ne/xml vs ...
Her maç için nasıl normal ifade belirl...