1
0
Fork 0
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:
Javan Makhmali 2015-06-27 13:13:44 -04:00
parent 16849a7e68
commit d2c613cd8f

View file

@ -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()
@open()
if @isClosed()
@open()
else
@websocket.onclose = @open
@websocket.onerror = @open
@websocket.close()
isOpen: ->
@websocket.readyState is WebSocket.OPEN