           type:"kodingKey",
           key:"NPhFRpZPYuWA4kFA7Y0ewEIQy7qdgj3ij6tegRQ9sd2s-g2-Debdi20fStRiIM5Z"
 
-
       scrubber.scrub [payload, callback], =>
-          scrubbed = scrubber.toDnodeProtocol()
-          scrubbed.method = method
-          message = JSON.stringify scrubbed
-          @ws.send message
+        console.log "!!!! 1"
+        scrubbed = scrubber.toDnodeProtocol()
+        scrubbed.method = method
+        console.log "2"
+        message = JSON.stringify scrubbed
+        console.log "3"
+        @ws.send message
 
     getKites: (callback=noop)->
       @callRemote "getKites",

        version: "1" # <--- this should always be a string, dont ask me why, its not an integer
        hostname: "aybarss-MacBook-Air.local"
        publicIP:""
        port:"62428"
      payload.withArgs = args
      payload.links = []


WebSocket = require 'ws'
WebSocketServer = require('ws').Server

{EventEmitter} = require 'events'
{Scrubber, Store} = require 'koding-dnode-protocol'
noop = ->


class KiteClient extends EventEmitter
    constructor: (@options, @remoteAddr='ws://localhost:4000/dnode')->
      @localStore = new Store
      @remoteStore = new Store

      self = this
      @api =
        heartbeat: (k)->
          console.log ">>>>>", "heartbeat called", k.withArgs[1]
          remoteFn = k.withArgs[1]
          setInterval ()->
            remoteFn()
          , 1000

    connect: (callback=noop)->
      @ws = new WebSocket @remoteAddr
