 
   reopen: ->
     console.log("[cable] Reopening WebSocket, current state is #{@getState()}", Date.now())
-    if @isState("closed")
+    if @isClosed()
       @open()
     else
       try

    @isState("open")

  # Private

  isState: (states...) ->
    @getState() in states

      false

  open: =>
    if @webSocket and not @isClosed()
      console.log("[cable] Attemped to open WebSocket, but existing socket is #{@getState()}", Date.now())
      throw new Error("Existing connection must be closed before opening")
    else
      console.log("[cable] Opening WebSocket, current state is #{@getState()}", Date.now())
      @webSocket = new WebSocket(@consumer.url)
      @installEventHandlers()
      true
