summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorWu Cheng-Han2017-01-02 10:52:47 +0800
committerWu Cheng-Han2017-01-02 10:52:47 +0800
commitc904083d1f5064d2e786e0bc6ee3804b91805d24 (patch)
treef37233e855abc6e245b8136d33aab3954dec9b23 /lib
parente65e09215a6e55e50bc01e14e02f6c2ac5ef584e (diff)
Remove manual LZString compression for partial socket io event data
Diffstat (limited to '')
-rwxr-xr-xlib/ot/editor-socketio-server.js8
-rw-r--r--lib/realtime.js4
2 files changed, 2 insertions, 10 deletions
diff --git a/lib/ot/editor-socketio-server.js b/lib/ot/editor-socketio-server.js
index d062fa19..7b204539 100755
--- a/lib/ot/editor-socketio-server.js
+++ b/lib/ot/editor-socketio-server.js
@@ -7,7 +7,6 @@ var Server = require('./server');
var Selection = require('./selection');
var util = require('util');
-var LZString = require('lz-string');
var logger = require('../logger');
function EditorSocketIOServer(document, operations, docId, mayWrite, operationCallback) {
@@ -40,10 +39,8 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
revision: this.operations.length,
clients: this.users
};
- socket.emit('doc', LZString.compressToUTF16(JSON.stringify(docOut)));
+ socket.emit('doc', docOut);
socket.on('operation', function (revision, operation, selection) {
- operation = LZString.decompressFromUTF16(operation);
- operation = JSON.parse(operation);
socket.origin = 'operation';
self.mayWrite(socket, function (mayWrite) {
if (!mayWrite) {
@@ -62,7 +59,7 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
clients: self.users,
force: true
};
- socket.emit('doc', LZString.compressToUTF16(JSON.stringify(docOut)));
+ socket.emit('doc', docOut);
}, 100);
}
});
@@ -129,7 +126,6 @@ EditorSocketIOServer.prototype.onGetOperations = function (socket, base, head) {
var operations = this.operations.slice(base, head).map(function (op) {
return op.wrapped.toJSON();
});
- operations = LZString.compressToUTF16(JSON.stringify(operations));
socket.emit('operations', head, operations);
};
diff --git a/lib/realtime.js b/lib/realtime.js
index c243ffc1..c66fea0a 100644
--- a/lib/realtime.js
+++ b/lib/realtime.js
@@ -71,7 +71,6 @@ function emitCheck(note) {
authors: note.authors,
authorship: note.authorship
};
- out = LZString.compressToUTF16(JSON.stringify(out));
realtime.io.to(note.id).emit('check', out);
}
@@ -301,7 +300,6 @@ function emitOnlineUsers(socket) {
var out = {
users: users
};
- out = LZString.compressToUTF16(JSON.stringify(out));
realtime.io.to(noteId).emit('online users', out);
}
@@ -330,7 +328,6 @@ function emitRefresh(socket) {
createtime: note.createtime,
updatetime: note.updatetime
};
- out = LZString.compressToUTF16(JSON.stringify(out));
socket.emit('refresh', out);
}
@@ -863,7 +860,6 @@ function connection(socket) {
var out = {
users: users
};
- out = LZString.compressToUTF16(JSON.stringify(out));
socket.emit('online users', out);
});