From d14c5bdc9cabf632262067466ef02374cee496cd Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Thu, 16 Jul 2015 22:46:06 +0800 Subject: Added document max length limit, enforceMaxLength on change and show modal when reach the limit. --- lib/realtime.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'lib/realtime.js') 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]); } } -- cgit v1.2.3