Keep web socket connections down after session got disabled.

This commit is contained in:
Martin Edenhofer 2013-06-02 23:55:11 +02:00
parent b7a675874c
commit 76dd162d54
2 changed files with 10 additions and 2 deletions

View file

@ -42,6 +42,7 @@ class App.TaskWidget extends App.Controller
# disable all delay's and interval's # disable all delay's and interval's
App.Delay.reset() App.Delay.reset()
App.Interval.reset() App.Interval.reset()
App.WebSocket.close( force: true )
render: -> render: ->

View file

@ -37,6 +37,7 @@ class _Singleton extends App.Controller
queue: [] queue: []
supported: true supported: true
lastSpoolMessage: undefined lastSpoolMessage: undefined
connectionKeepDown: false
connectionEstablished: false connectionEstablished: false
connectionWasEstablished: false connectionWasEstablished: false
tryToConnect: false tryToConnect: false
@ -67,7 +68,7 @@ class _Singleton extends App.Controller
else else
# console.log 'ws:send trying', data, @ws, @ws.readyState # console.log 'ws:send trying', data, @ws, @ws.readyState
# A value of 0 indicates that the connection has not yet been established. # A value of 0 indicates that the connection has not yet been established.
# A value of 1 indicates that the connection is established and communication is possible. # A value of 1 indicates that the connection is established and communication is possible.
# A value of 2 indicates that the connection is going through the closing handshake. # A value of 2 indicates that the connection is going through the closing handshake.
@ -106,7 +107,10 @@ class _Singleton extends App.Controller
# set timestamp to get spool messages later # set timestamp to get spool messages later
@lastSpoolMessage = Math.round( +new Date()/1000 ) @lastSpoolMessage = Math.round( +new Date()/1000 )
close: => close: ( params = {} ) =>
if params['force']
@connectionKeepDown = true
return if @backend is 'ajax' return if @backend is 'ajax'
@ws.close() @ws.close()
@ -179,6 +183,9 @@ class _Singleton extends App.Controller
@ws.onclose = (e) => @ws.onclose = (e) =>
@log 'Websocket', 'debug', "ws:onclose", e @log 'Websocket', 'debug', "ws:onclose", e
# take connection down and keep it down
return if @connectionKeepDown
# set timestamp to get spool messages later # set timestamp to get spool messages later
if @connectionEstablished if @connectionEstablished
@lastSpoolMessage = Math.round( +new Date()/1000 ) @lastSpoolMessage = Math.round( +new Date()/1000 )