Commit e25b5126 authored by Alexander.Trofimov's avatar Alexander.Trofimov

refactoring code style function _initSocksJs

parent cabad702
...@@ -1533,7 +1533,7 @@ ...@@ -1533,7 +1533,7 @@
}); });
}; };
DocsCoApi.prototype._initSocksJs = function() { DocsCoApi.prototype._initSocksJs = function () {
var t = this; var t = this;
var sockjs; var sockjs;
...@@ -1544,10 +1544,11 @@ ...@@ -1544,10 +1544,11 @@
} else { } else {
//ограничиваем transports WebSocket и XHR / JSONP polling, как и engine.io https://github.com/socketio/engine.io //ограничиваем transports WebSocket и XHR / JSONP polling, как и engine.io https://github.com/socketio/engine.io
//при переборе streaming transports у клиента с wirewall происходило зацикливание(не повторялось в версии sock.js 0.3.4) //при переборе streaming transports у клиента с wirewall происходило зацикливание(не повторялось в версии sock.js 0.3.4)
sockjs = this.sockjs = new (AscCommon.getSockJs())(this.sockjs_url, null, {'transports': ['websocket', 'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling']}); sockjs = this.sockjs = new (AscCommon.getSockJs())(this.sockjs_url, null,
{'transports': ['websocket', 'xdr-polling', 'xhr-polling', 'iframe-xhr-polling', 'jsonp-polling']});
} }
sockjs.onopen = function() { sockjs.onopen = function () {
if (t.reconnectTimeout) { if (t.reconnectTimeout) {
clearTimeout(t.reconnectTimeout); clearTimeout(t.reconnectTimeout);
t.reconnectTimeout = null; t.reconnectTimeout = null;
...@@ -1557,7 +1558,7 @@ ...@@ -1557,7 +1558,7 @@
t._state = ConnectionState.WaitAuth; t._state = ConnectionState.WaitAuth;
t.onFirstConnect(); t.onFirstConnect();
}; };
sockjs.onmessage = function(e) { sockjs.onmessage = function (e) {
//TODO: add checks and error handling //TODO: add checks and error handling
//Get data type //Get data type
var dataObject = JSON.parse(e.data); var dataObject = JSON.parse(e.data);
...@@ -1629,7 +1630,7 @@ ...@@ -1629,7 +1630,7 @@
break; break;
} }
}; };
sockjs.onclose = function(evt) { sockjs.onclose = function (evt) {
if (ConnectionState.SaveChanges === t._state) { if (ConnectionState.SaveChanges === t._state) {
// Мы сохраняли изменения и разорвалось соединение // Мы сохраняли изменения и разорвалось соединение
t._isReSaveAfterAuth = true; t._isReSaveAfterAuth = true;
...@@ -1639,7 +1640,8 @@ ...@@ -1639,7 +1640,8 @@
} }
} }
t._state = ConnectionState.Reconnect; t._state = ConnectionState.Reconnect;
var bIsDisconnectAtAll = ((c_oCloseCode.serverShutdown <= evt.code && evt.code <= c_oCloseCode.jwtError) || t.attemptCount >= t.maxAttemptCount); var bIsDisconnectAtAll = ((c_oCloseCode.serverShutdown <= evt.code && evt.code <= c_oCloseCode.jwtError) ||
t.attemptCount >= t.maxAttemptCount);
var errorCode = null; var errorCode = null;
if (bIsDisconnectAtAll) { if (bIsDisconnectAtAll) {
t._state = ConnectionState.ClosedAll; t._state = ConnectionState.ClosedAll;
......
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