summaryrefslogtreecommitdiff
path: root/lib/ot
diff options
context:
space:
mode:
authorWu Cheng-Han2016-01-17 09:51:27 -0600
committerWu Cheng-Han2016-01-17 09:51:27 -0600
commit49c7dded4539044d8053dba8d3fe24b97056c0d2 (patch)
tree00fa3f5fd293cc810daa7a2142bc7578de6f422f /lib/ot
parent473212676ade788b6603a7a3c2bec726c6ca1579 (diff)
Added private permission and clean up codes, solved potential race condition in realtime.js
Diffstat (limited to 'lib/ot')
-rwxr-xr-xlib/ot/editor-socketio-server.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/ot/editor-socketio-server.js b/lib/ot/editor-socketio-server.js
index 1b2529be..9e4ddf96 100755
--- a/lib/ot/editor-socketio-server.js
+++ b/lib/ot/editor-socketio-server.js
@@ -43,6 +43,7 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
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) {
console.log("User doesn't have the right to edit.");
@@ -59,6 +60,7 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
self.onGetOperations(socket, base, head);
});
socket.on('selection', function (obj) {
+ socket.origin = 'selection';
self.mayWrite(socket, function (mayWrite) {
if (!mayWrite) {
console.log("User doesn't have the right to edit.");
@@ -104,6 +106,7 @@ EditorSocketIOServer.prototype.onOperation = function (socket, revision, operati
'operation', clientId, revision,
wrappedPrime.wrapped.toJSON(), wrappedPrime.meta
);
+ //set document is dirty
this.isDirty = true;
} catch (exc) {
logger.error(exc);