1
0
Fork 0
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:
Javan Makhmali 2015-10-14 17:06:21 -05:00
parent 60d2f4becb
commit e07972711e

View file

@ -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()