From 68eaa09708241b0551f5d345f45d8f7ba00913d2 Mon Sep 17 00:00:00 2001 From: John McLear Date: Tue, 4 Nov 2014 19:55:05 +0000 Subject: Begin to repair damage done to rooms logic --- src/node/handler/PadMessageHandler.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index da2a7a14..2072a784 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -754,9 +754,14 @@ function handleUserChanges(data, cb) exports.updatePadClients = function(pad, callback) { - /* //skip this step if noone is on this pad - var roomClients = socketio.sockets.clients(pad.id); + var roomClients = [], room = socketio.sockets.adapter.rooms[pad.id]; + if (room) { + for (var id in room) { + roomClients.push(socketio.sockets.adapter.nsp.connected[id]); + } + } + if(roomClients.length==0) return callback(); @@ -769,10 +774,8 @@ exports.updatePadClients = function(pad, callback) var revCache = {}; //go trough all sessions on this pad - async.forEach(roomClients, function(client, callback) - { + async.forEach(roomClients, function(client, callback){ var sid = client.id; - //https://github.com/caolan/async#whilst //send them all new changesets async.whilst( @@ -802,7 +805,8 @@ exports.updatePadClients = function(pad, callback) if(author == sessioninfos[sid].author) { - client.json.send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); + // client.json.send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); + socketio.in(pad).send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); } else { @@ -817,7 +821,9 @@ exports.updatePadClients = function(pad, callback) timeDelta: currentTime - sessioninfos[sid].time }}; - client.json.send(wireMsg); + // client.json.send(wireMsg); + socketio.in(pad).send({"type":"COLLABROOM","data":{type:"ACCEPT_COMMIT", newRev:r}}); + } sessioninfos[sid].time = currentTime; @@ -830,7 +836,6 @@ exports.updatePadClients = function(pad, callback) callback ); },callback); - */ } /** -- cgit v1.2.3