From 2f117a22cd21fa4fb67a3b2d687485795f86d030 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Sat, 30 Jul 2016 11:21:38 +0800 Subject: Add support of saving authors and authorship --- lib/ot/editor-socketio-server.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/ot/editor-socketio-server.js') diff --git a/lib/ot/editor-socketio-server.js b/lib/ot/editor-socketio-server.js index 9e4ddf96..45ed5036 100755 --- a/lib/ot/editor-socketio-server.js +++ b/lib/ot/editor-socketio-server.js @@ -10,7 +10,7 @@ var util = require('util'); var LZString = require('lz-string'); var logger = require('../logger'); -function EditorSocketIOServer(document, operations, docId, mayWrite) { +function EditorSocketIOServer(document, operations, docId, mayWrite, operationCallback) { EventEmitter.call(this); Server.call(this, document, operations); this.users = {}; @@ -18,6 +18,7 @@ function EditorSocketIOServer(document, operations, docId, mayWrite) { this.mayWrite = mayWrite || function (_, cb) { cb(true); }; + this.operationCallback = operationCallback; } util.inherits(EditorSocketIOServer, Server); @@ -51,6 +52,8 @@ EditorSocketIOServer.prototype.addClient = function (socket) { } try { self.onOperation(socket, revision, operation, selection); + if (typeof self.operationCallback === 'function') + self.operationCallback(socket, operation); } catch (err) { socket.disconnect(true); } -- cgit v1.2.3