mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Wait for connection to close before reopening it
This commit is contained in:
parent
16849a7e68
commit
d2c613cd8f
1 changed files with 7 additions and 4 deletions
|
@ -12,20 +12,23 @@ class Cable.Connection
|
|||
else
|
||||
false
|
||||
|
||||
open: ->
|
||||
open: =>
|
||||
@websocket = new WebSocket(@consumer.url)
|
||||
@websocket.onmessage = @onMessage
|
||||
@websocket.onopen = @onOpen
|
||||
@websocket.onclose = @onClose
|
||||
@websocket.onerror = @onError
|
||||
@websocket
|
||||
|
||||
close: ->
|
||||
@websocket.close() unless @isClosed()
|
||||
|
||||
reopen: ->
|
||||
@close()
|
||||
if @isClosed()
|
||||
@open()
|
||||
else
|
||||
@websocket.onclose = @open
|
||||
@websocket.onerror = @open
|
||||
@websocket.close()
|
||||
|
||||
isOpen: ->
|
||||
@websocket.readyState is WebSocket.OPEN
|
||||
|
|
Loading…
Reference in a new issue