Added missing ajax reconnect on error.
This commit is contained in:
parent
388437ef18
commit
e250680284
1 changed files with 9 additions and 5 deletions
|
@ -138,7 +138,7 @@ class _Singleton extends App.Controller
|
||||||
@log 'Websocket', 'debug', 'received websockend ping'
|
@log 'Websocket', 'debug', 'received websockend ping'
|
||||||
|
|
||||||
# test again after 1 min
|
# test again after 1 min
|
||||||
@delay @ping, 60000, undefined, 'ws'
|
@delay @ping, 60000, 'websocket-pong', 'ws'
|
||||||
|
|
||||||
connect: =>
|
connect: =>
|
||||||
return if @backend is 'ajax'
|
return if @backend is 'ajax'
|
||||||
|
@ -177,7 +177,7 @@ class _Singleton extends App.Controller
|
||||||
@queue = []
|
@queue = []
|
||||||
|
|
||||||
# send ping to check connection
|
# send ping to check connection
|
||||||
@delay @ping, 60000, undefined, 'ws'
|
@delay @ping, 60000, 'websocket-send-ping-to-heck-connection', 'ws'
|
||||||
|
|
||||||
@ws.onmessage = (e) =>
|
@ws.onmessage = (e) =>
|
||||||
pipe = JSON.parse( e.data )
|
pipe = JSON.parse( e.data )
|
||||||
|
@ -213,11 +213,11 @@ class _Singleton extends App.Controller
|
||||||
message: 'No connection to websocket, trying to reconnect...'
|
message: 'No connection to websocket, trying to reconnect...'
|
||||||
)
|
)
|
||||||
if !@tryToConnect
|
if !@tryToConnect
|
||||||
@delay message, 7000, 'websocket-no-connection-try-reconnect', 'ws'
|
@delay message, 7000, 'websocket-no-connection-try-reconnect-message', 'ws'
|
||||||
@tryToConnect = true
|
@tryToConnect = true
|
||||||
|
|
||||||
# try reconnect after 4.5 sec.
|
# try reconnect after 4.5 sec.
|
||||||
@delay @connect, 4500, undefined, 'ws'
|
@delay @connect, 4500, 'websocket-try-reconnect-after-x-sec', 'ws'
|
||||||
|
|
||||||
@ws.onerror = (e) =>
|
@ws.onerror = (e) =>
|
||||||
@log 'Websocket', 'debug', "ws:onerror", e
|
@log 'Websocket', 'debug', "ws:onerror", e
|
||||||
|
@ -272,6 +272,11 @@ class _Singleton extends App.Controller
|
||||||
error: =>
|
error: =>
|
||||||
@_ajaxInitDone = true
|
@_ajaxInitDone = true
|
||||||
@_ajaxInitWorking = false
|
@_ajaxInitWorking = false
|
||||||
|
|
||||||
|
# try reconnect on error after x sec.
|
||||||
|
reconnect = =>
|
||||||
|
@_ajaxInit( force: true )
|
||||||
|
@delay reconnect, 10000, '_ajaxInit-reconnect-on-error', 'ws'
|
||||||
)
|
)
|
||||||
|
|
||||||
_ajaxSend: (data) =>
|
_ajaxSend: (data) =>
|
||||||
|
@ -323,5 +328,4 @@ class _Singleton extends App.Controller
|
||||||
@client_id = undefined
|
@client_id = undefined
|
||||||
@_ajaxInit( force: true )
|
@_ajaxInit( force: true )
|
||||||
@_ajaxReceiveWorking = false
|
@_ajaxReceiveWorking = false
|
||||||
@delay @_ajaxReceive, 5000, undefined, 'ws'
|
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue