 
   send: (data) ->
     if @isOpen()
-      @websocket.send(JSON.stringify(data))
+      @webSocket.send(JSON.stringify(data))
       true
     else
       false
 
   open: =>
     return if @isState("open", "connecting")
-    @websocket = new WebSocket(@consumer.url)
-    @websocket.onmessage = @onMessage
-    @websocket.onopen    = @onOpen
-    @websocket.onclose   = @onClose
-    @websocket.onerror   = @onError
+    @webSocket = new WebSocket(@consumer.url)
+    @webSocket.onmessage = @onMessage
+    @webSocket.onopen    = @onOpen
+    @webSocket.onclose   = @onClose
+    @webSocket.onerror   = @onError
 
   close: ->
     return if @isState("closed", "closing")
-    @websocket?.close()
+    @webSocket?.close()
 
   reopen: ->
     if @isOpen()
-      @websocket.onclose = @open
-      @websocket.onerror = @open
-      @websocket.close()
+      @webSocket.onclose = @open
+      @webSocket.onerror = @open
+      @webSocket.close()
     else
       @open()
 


  onError: =>
    @disconnect()
    @websocket.onclose = -> # no-op
    @websocket.onerror = -> # no-op
    try @close()

  disconnect: ->

    @getState() in states

  getState: ->
    return state.toLowerCase() for state, value of WebSocket when value is @webSocket?.readyState
    null

  onMessage: (message) =>
