       else
         @emit "connectionFailed"
 
-  ready:(callback)->
+  ready: (callback)->
     return KD.utils.defer callback  if @readyState
     @once 'ready', callback
 

    @autoReconnect = !!reconnect  if reconnect?
    @ws.close()

  onOpen: ->
    console.log "connected"
    @clearBackoffTimeout()
    @readyState = READY
    @emit 'ready'
    @emit 'connected'

  onClose : (evt) ->
    console.log "#{@kiteName}: Disconnected"
    @readyState = CLOSED
    if @autoReconnect
      KD.utils.defer => @setBackoffTimeout @bound "connect"

  onMessage : (evt) ->
    try
      args = JSON.parse evt.data
      {method} = args

    catch e
      console.log "error: ", e, evt.data

  onError: (evt) ->
    # console.log "#{@kiteName}: error #{evt.data}"

  initBackoff:(options)->
    backoff = options.backoff ? {}
