     console.log {method}, {args}
     @scrub method, args, (scrubbed) =>
       messageString = JSON.stringify(scrubbed)
-      console.log "Sending", {messageString}
-      @ready => @websocket.send messageString
+      @ready => @send scrubbed
 
   scrub: (method, args, callback) ->
     scrubber = new Scrubber @localStore


  { Scrubber, Store } = Bongo.dnodeProtocol

  constructor: (options)->
    super

    { @kiteName, @correlationName, @kiteKey } = options

    @localStore   = new Store
    @remoteStore  = new Store

    @readyState = false
    @token = ""
    @getKiteAddr()

  createWebSocket: (url) ->
    new WebSocket "ws://#{url}/sock"

  getKiteAddr:()->
    requestData =

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

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

  initBackoff:(options)->
    backoff = options.backoff ? {}
    totalReconnectAttempts = 0
    initalDelayMs = backoff.initialDelayMs ? 700
    multiplyFactor = backoff.multiplyFactor ? 1.4
    maxDelayMs = backoff.maxDelayMs ? 1000 * 15 # 15 seconds
    maxReconnectAttempts = backoff.maxReconnectAttempts ? 50

    @clearBackoffTimeout =->
      totalReconnectAttempts = 0

    @setBackoffTimeout = (fn)=>
      if totalReconnectAttempts < maxReconnectAttempts
        timeout = Math.min initalDelayMs * Math.pow(
          multiplyFactor, totalReconnectAttempts
        ), maxDelayMs
        setTimeout fn, timeout
        totalReconnectAttempts++
      else
        @emit "connectionFailed"

  ready:(callback)->
    return KD.utils.defer callback  if @readyState
