In der 0.9.x-Version können wir Buchse von ID wie diese:Socket.IO 1.0.x: Get-Buchse von id
io.sockets.socket(socketId)
Aber in 1.0.x können wir nicht. Wie finde ich einen Sockel nach ID in 1.0.x?
In der 0.9.x-Version können wir Buchse von ID wie diese:Socket.IO 1.0.x: Get-Buchse von id
io.sockets.socket(socketId)
Aber in 1.0.x können wir nicht. Wie finde ich einen Sockel nach ID in 1.0.x?
Für socket.io 1.0 Verwendung:
io.sockets.connected[socketId]
Für 0.9 seine io.sockets.sockets [SocketId] und io.sockets.socket nicht [SocketId]
Sie können auch wie verwenden:
io.to(socketid).emit();
Socket.io Version 2.0.3+
let namespace = null;
let ns = _io.of(namespace || "/");
let socket = ns.connected[socketId] // assuming you have id of the socket
Danke, es funktioniert –
Für Namespace-Verbindungen konnte ich nicht über 'io.sockets.connected [socketId] .emit()' darauf zugreifen, aber es funktioniert ähnlich 'var nsp = io.of ('/ my-namespace'); 'dann' nsp.connected [socketId] .emit() '. Vielen Dank – Luckylooke