mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-28 22:34:26 -05:00
Handle when OT throw Error, will log it then disconnect socket client
This commit is contained in:
parent
f678bf7205
commit
1b92300445
1 changed files with 11 additions and 4 deletions
|
@ -8,6 +8,7 @@ var Selection = require('./selection');
|
||||||
var util = require('util');
|
var util = require('util');
|
||||||
|
|
||||||
var LZString = require('lz-string');
|
var LZString = require('lz-string');
|
||||||
|
var logger = require('../logger');
|
||||||
|
|
||||||
function EditorSocketIOServer(document, operations, docId, mayWrite) {
|
function EditorSocketIOServer(document, operations, docId, mayWrite) {
|
||||||
EventEmitter.call(this);
|
EventEmitter.call(this);
|
||||||
|
@ -47,7 +48,11 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
|
||||||
console.log("User doesn't have the right to edit.");
|
console.log("User doesn't have the right to edit.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
self.onOperation(socket, revision, operation, selection);
|
self.onOperation(socket, revision, operation, selection);
|
||||||
|
} catch (err) {
|
||||||
|
socket.disconnect();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
socket.on('get_operations', function (base, head) {
|
socket.on('get_operations', function (base, head) {
|
||||||
|
@ -82,8 +87,9 @@ EditorSocketIOServer.prototype.onOperation = function (socket, revision, operati
|
||||||
selection && Selection.fromJSON(selection)
|
selection && Selection.fromJSON(selection)
|
||||||
);
|
);
|
||||||
} catch (exc) {
|
} catch (exc) {
|
||||||
console.error("Invalid operation received: " + exc);
|
logger.error("Invalid operation received: ");
|
||||||
return;
|
logger.error(exc);
|
||||||
|
throw new Error(exc);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -99,7 +105,8 @@ EditorSocketIOServer.prototype.onOperation = function (socket, revision, operati
|
||||||
);
|
);
|
||||||
this.isDirty = true;
|
this.isDirty = true;
|
||||||
} catch (exc) {
|
} catch (exc) {
|
||||||
console.error(exc);
|
logger.error(exc);
|
||||||
|
throw new Error(exc);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue