 
   { Scrubber, Store } = Bongo.dnodeProtocol
 
+  [NOTREADY, READY, CLOSED] = [0,1,3]
+
   constructor: (options)->
     super
-
     { @kiteName, @correlationName, @kiteKey } = options
-
     @localStore   = new Store
     @remoteStore  = new Store
+    @autoReconnect = true
+    @readyState = NOTREADY
+    @token = ""
+    @addr = ""
+    @initBackoff options  if @autoReconnect
+    @connect()
 
-    @readyState = false
-    @token = ""
-    @getKiteAddr()
+  connect:->
+    if @addr
+    then @connectDirectly()
+    else @getKiteAddr()
 
-  createWebSocket: (url) ->
-    new WebSocket "ws://#{url}/sock"
+  bound: Bongo.bound
+
+  connectDirectly:->
+    @ws = new WebSocket "ws://#{@addr}/sock"
+    @ws.onopen    = @bound 'onOpen'
+    @ws.onclose   = @bound 'onClose'
+    @ws.onmessage = @bound 'onMessage'
+    @ws.onerror   = @bound 'onError'
 
   getKiteAddr:()->
     requestData =

      remoteKite : @kiteName
      token      : KD.remote.getSessionToken()

    $.ajax
     type    : "POST"
     url     : "http://127.0.0.1:4000/request" #kontrol addr
     data    : JSON.stringify requestData
     success: (data, status, response) =>
       if response.status is 200
         data = JSON.parse data

         console.log "DATA", data

         console.log "Remote Kite belongs to: #{data[0].username}, type: #{data[0].kitename}"
         console.log "Addr to be connected is #{data[0].addr}"
         console.log "Token to use is #{data[0].token}"

         @token = data[0].token
         @websocket = @createWebSocket(data[0].addr)
         @registerEvents()

     error: (data, status, response) ->
       console.log "error kontrol kite request", data, status, response

  registerEvents:()->
    @websocket.onopen = (evt) => @onOpen evt
    @websocket.onclose = (evt) => @onClose evt
    @websocket.onmessage = (evt) => @onMessage evt
    @websocket.onerror = (evt) => @onError evt

  onOpen :(evt) ->
    @readyState = true
    @emit 'ready'

  onClose : (evt) -> console.log "#{@kiteName}: Disconnected"

  onMessage : (evt) ->
    try

    console.log {method}, {args}
    @scrub method, args, (scrubbed) =>
      messageString = JSON.stringify(scrubbed)
      @ready => @send scrubbed

  scrub: (method, args, callback) ->
    scrubber = new Scrubber @localStore
