Update to make OT socket io handle error better, use delay to avoid wrong reversion on client

This commit is contained in:
Wu Cheng-Han 2016-10-10 20:40:45 +08:00
parent 73a8a6c32a
commit a090008d4a
1 changed files with 9 additions and 1 deletions

View File

@ -55,7 +55,15 @@ EditorSocketIOServer.prototype.addClient = function (socket) {
if (typeof self.operationCallback === 'function') if (typeof self.operationCallback === 'function')
self.operationCallback(socket, operation); self.operationCallback(socket, operation);
} catch (err) { } catch (err) {
socket.disconnect(true); setTimeout(function() {
var docOut = {
str: self.document,
revision: self.operations.length,
clients: self.users,
force: true
};
socket.emit('doc', LZString.compressToUTF16(JSON.stringify(docOut)));
}, 100);
} }
}); });
}); });