]> git.r.bdr.sh - rbdr/junction/blobdiff - server/index.js
Update for socket.io 4
[rbdr/junction] / server / index.js
index 56a1df48e84b4411ea51b4ea49c9511bee93286a..37104e1d717ed0bacd028412c7fc98b077bd6039 100644 (file)
@@ -15,7 +15,7 @@ server.on('connection', (socket) => {
 
     socket.on('join', (data) => {
         socket.join(data.url);
 
     socket.on('join', (data) => {
         socket.join(data.url);
-        const sockets = server.sockets.adapter.rooms.get(data.url);
+        const sockets = server.of(data.url).sockets.keys();
         sockets.forEach((peerId) => {
             if (peerId !== me) {
                 const peer = server.sockets.sockets.get(peerId)
         sockets.forEach((peerId) => {
             if (peerId !== me) {
                 const peer = server.sockets.sockets.get(peerId)
@@ -34,7 +34,7 @@ server.on('connection', (socket) => {
     });
 
     socket.on('relayICECandidate', (data) => {
     });
 
     socket.on('relayICECandidate', (data) => {
-        const sockets = server.sockets.adapter.rooms.get(data.url);
+        const sockets = server.of(data.url).sockets.keys();
         sockets.forEach((peerId) => {
             const peer = server.sockets.sockets.get(peerId)
             peer.emit(events.types.ICE_CANDIDATE_RECEIVED, events.ICECandidateReceived(me, data.ice_candidate))
         sockets.forEach((peerId) => {
             const peer = server.sockets.sockets.get(peerId)
             peer.emit(events.types.ICE_CANDIDATE_RECEIVED, events.ICECandidateReceived(me, data.ice_candidate))
@@ -44,7 +44,7 @@ server.on('connection', (socket) => {
     });
 
     socket.on('relaySessionDescription', (data) => {
     });
 
     socket.on('relaySessionDescription', (data) => {
-        const sockets = server.sockets.adapter.rooms.get(data.url);
+        const sockets = server.of(data.url).sockets.keys();
         sockets.forEach((peerId) => {
             const peer = server.sockets.sockets.get(peerId)
             peer.emit(events.types.SESSION_DESCRIPTION_RECEIVED, events.SessionDescriptionReceived(me, data.session_description))
         sockets.forEach((peerId) => {
             const peer = server.sockets.sockets.get(peerId)
             peer.emit(events.types.SESSION_DESCRIPTION_RECEIVED, events.SessionDescriptionReceived(me, data.session_description))