Add support of saving authors and authorship

This commit is contained in:
Wu Cheng-Han 2016-07-30 11:21:38 +08:00
parent 44fd0a617b
commit 2f117a22cd
6 changed files with 240 additions and 3 deletions

View file

@ -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);
}