Commit 5640d7f2 authored by Alexander.Trofimov's avatar Alexander.Trofimov

move sockjs.onmessage into a separate function _onServerMessage

parent e25b5126
......@@ -1559,76 +1559,7 @@
t.onFirstConnect();
};
sockjs.onmessage = function (e) {
//TODO: add checks and error handling
//Get data type
var dataObject = JSON.parse(e.data);
switch (dataObject['type']) {
case 'auth' :
t._onAuth(dataObject);
break;
case 'message' :
t._onMessages(dataObject, false);
break;
case 'cursor' :
t._onCursor(dataObject);
break;
case 'meta' :
t._onMeta(dataObject);
break;
case 'getLock' :
t._onGetLock(dataObject);
break;
case 'releaseLock' :
t._onReleaseLock(dataObject);
break;
case 'connectState' :
t._onConnectionStateChanged(dataObject);
break;
case 'saveChanges' :
t._onSaveChanges(dataObject);
break;
case 'saveLock' :
t._onSaveLock(dataObject);
break;
case 'unSaveLock' :
t._onUnSaveLock(dataObject);
break;
case 'savePartChanges' :
t._onSavePartChanges(dataObject);
break;
case 'drop' :
t._onDrop(dataObject);
break;
case 'waitAuth' : /*Ждем, когда придет auth, документ залочен*/
break;
case 'error' : /*Старая версия sdk*/
t._onDrop(dataObject);
break;
case 'documentOpen' :
t._documentOpen(dataObject);
break;
case 'warning':
t._onWarning(dataObject);
break;
case 'license':
t._onLicense(dataObject);
break;
case 'session' :
t._onSession(dataObject);
break;
case 'refreshToken' :
t._onRefreshToken(dataObject["messages"]);
break;
case 'expiredToken' :
t._onExpiredToken();
break;
case 'forceSaveStart' :
t._onForceSaveStart(dataObject["messages"]);
break;
case 'forceSave' :
t._onForceSave(dataObject["messages"]);
break;
}
t._onServerMessage(e.data);
};
sockjs.onclose = function (evt) {
if (ConnectionState.SaveChanges === t._state) {
......@@ -1659,6 +1590,78 @@
return sockjs;
};
DocsCoApi.prototype._onServerMessage = function (data) {
//TODO: add checks and error handling
//Get data type
var dataObject = JSON.parse(data);
switch (dataObject['type']) {
case 'auth' :
t._onAuth(dataObject);
break;
case 'message' :
t._onMessages(dataObject, false);
break;
case 'cursor' :
t._onCursor(dataObject);
break;
case 'meta' :
t._onMeta(dataObject);
break;
case 'getLock' :
t._onGetLock(dataObject);
break;
case 'releaseLock' :
t._onReleaseLock(dataObject);
break;
case 'connectState' :
t._onConnectionStateChanged(dataObject);
break;
case 'saveChanges' :
t._onSaveChanges(dataObject);
break;
case 'saveLock' :
t._onSaveLock(dataObject);
break;
case 'unSaveLock' :
t._onUnSaveLock(dataObject);
break;
case 'savePartChanges' :
t._onSavePartChanges(dataObject);
break;
case 'drop' :
t._onDrop(dataObject);
break;
case 'waitAuth' : /*Ждем, когда придет auth, документ залочен*/
break;
case 'error' : /*Старая версия sdk*/
t._onDrop(dataObject);
break;
case 'documentOpen' :
t._documentOpen(dataObject);
break;
case 'warning':
t._onWarning(dataObject);
break;
case 'license':
t._onLicense(dataObject);
break;
case 'session' :
t._onSession(dataObject);
break;
case 'refreshToken' :
t._onRefreshToken(dataObject["messages"]);
break;
case 'expiredToken' :
t._onExpiredToken();
break;
case 'forceSaveStart' :
t._onForceSaveStart(dataObject["messages"]);
break;
case 'forceSave' :
t._onForceSave(dataObject["messages"]);
break;
}
};
DocsCoApi.prototype._tryReconnect = function() {
var t = this;
if (this.reconnectTimeout) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment