diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/assets/javascripts/cable/connection.coffee | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/assets/javascripts/cable/connection.coffee b/lib/assets/javascripts/cable/connection.coffee index 2259ddcedd..8256f731c5 100644 --- a/lib/assets/javascripts/cable/connection.coffee +++ b/lib/assets/javascripts/cable/connection.coffee @@ -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() |