diff options
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/ot/editor-socketio-server.js | 1 | ||||
-rw-r--r-- | lib/ot/server.js | 7 | ||||
-rw-r--r-- | lib/realtime.js | 17 |
3 files changed, 16 insertions, 9 deletions
diff --git a/lib/ot/editor-socketio-server.js b/lib/ot/editor-socketio-server.js index ade8fc52..67920cbf 100755 --- a/lib/ot/editor-socketio-server.js +++ b/lib/ot/editor-socketio-server.js @@ -95,6 +95,7 @@ EditorSocketIOServer.prototype.onOperation = function (socket, revision, operati try { var clientId = socket.id; var wrappedPrime = this.receiveOperation(revision, wrapped); + if(!wrappedPrime) return; //console.log("new operation: " + JSON.stringify(wrapped)); this.getClient(clientId).selection = wrappedPrime.meta; revision = this.operations.length; diff --git a/lib/ot/server.js b/lib/ot/server.js index 608d434b..fec3b6f0 100644 --- a/lib/ot/server.js +++ b/lib/ot/server.js @@ -1,3 +1,5 @@ +var config = require('../../config'); + if (typeof ot === 'undefined') { var ot = {}; } @@ -28,7 +30,10 @@ ot.Server = (function (global) { } // ... and apply that on the document. - this.document = operation.apply(this.document); + var newDocument = operation.apply(this.document); + // ignore if exceed the max length of document + if(newDocument.length > config.documentmaxlength) return; + this.document = newDocument; // Store operation in history. this.operations.push(operation); diff --git a/lib/realtime.js b/lib/realtime.js index 3e367158..0b5a46b2 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -207,6 +207,7 @@ function emitRefresh(socket) { if (!notename || !notes[notename]) return; var note = notes[notename]; socket.emit('refresh', { + docmaxlength: config.documentmaxlength, owner: note.owner, permission: note.permission, updatetime: note.updatetime @@ -218,13 +219,12 @@ var connectionSocketQueue = []; var isDisconnectBusy = false; var disconnectSocketQueue = []; -function finishConnection(socket, notename) { - var note = notes[notename]; - note.users[socket.id] = users[socket.id]; +function finishConnection(socket, note, user) { + note.users[socket.id] = user; note.socks.push(socket); note.server.addClient(socket); - note.server.setName(socket, users[socket.id].name); - note.server.setColor(socket, users[socket.id].color); + note.server.setName(socket, user.name); + note.server.setColor(socket, user.color); emitOnlineUsers(socket); emitRefresh(socket); @@ -240,8 +240,9 @@ function finishConnection(socket, notename) { startConnection(connectionSocketQueue[0]); if (config.debug) { + var notename = getNotenameFromSocket(socket); logger.info('SERVER connected a client to [' + notename + ']:'); - logger.info(JSON.stringify(users[socket.id])); + logger.info(JSON.stringify(user)); //logger.info(notes); getStatus(function (data) { logger.info(JSON.stringify(data)); @@ -293,11 +294,11 @@ function startConnection(socket) { updatetime: moment(updatetime).valueOf(), server: server }; - finishConnection(socket, notename); + finishConnection(socket, notes[notename], users[socket.id]); }); }); } else { - finishConnection(socket, notename); + finishConnection(socket, notes[notename], users[socket.id]); } } |