mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Improve guard against opening multiple web sockets
This commit is contained in:
parent
60d2f4becb
commit
e07972711e
1 changed files with 4 additions and 3 deletions
|
@ -10,12 +10,13 @@ class Cable.Connection
|
|||
else
|
||||
false
|
||||
|
||||
open: ->
|
||||
if @isOpen()
|
||||
throw new Error("Must close existing connection before opening")
|
||||
open: =>
|
||||
if @webSocket and not @isState("closed")
|
||||
throw new Error("Existing connection must be closed before opening")
|
||||
else
|
||||
@webSocket = new WebSocket(@consumer.url)
|
||||
@installEventHandlers()
|
||||
true
|
||||
|
||||
close: ->
|
||||
@webSocket?.close()
|
||||
|
|
Loading…
Reference in a new issue