From b54b3cbe6957b46d3b689b0108b0b767b7da261b Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Mon, 10 Oct 2016 20:48:56 +0800 Subject: Add more comments in the code and remove unused code file --- lib/realtime.js | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/realtime.js b/lib/realtime.js index ae624c24..c9c6543c 100644 --- a/lib/realtime.js +++ b/lib/realtime.js @@ -518,13 +518,16 @@ function disconnect(socket) { var noteId = socket.noteId; var note = notes[noteId]; if (note) { + // delete user in users delete note.users[socket.id]; + // remove sockets in the note socks do { var index = note.socks.indexOf(socket); if (index != -1) { note.socks.splice(index, 1); } } while (index != -1); + // remove note in notes if no user inside if (Object.keys(note.users).length <= 0) { if (note.server.isDirty) { updateNote(note, function (err, _note) { -- cgit v1.2.3