     @ws.on "open", =>
       @robot.logger.info "Opened"
       @connected = true
-      @lastMessageSeen = Date.now
+      @lastMessageSeen = Date.now()
       @heartbeatTimeout = setInterval =>
         if not @connected then return
-        if Date.now - @lastMessageSeen > 30000
-          @robot.logger.error "Heartbeat too old at %ds", (Date.now - @lastMessageSeen) / 1000
-          @reconnect
+        if Date.now() - @lastMessageSeen > 30000
+          @robot.logger.error "Heartbeat too old at %ds", (Date.now() - @lastMessageSeen) / 1000
+          @reconnect()
         else
           @ws.send JSON.stringify({"type": "heartbeat"})
           @robot.logger.info "Sent heartbeat"

    @ws.close
    @connected = false
    setTimeout =>
      @connect
    , 5000

  websocketMessage: (packet) ->

      @websocketMessage JSON.parse data
    @ws.on "error", (error) =>
      @robot.logger.error error
      @reconnect()
    @ws.on "close", =>
      @robot.logger.info "Closed"
      @reconnect()
    @ws.on "ping", (data, flags) =>
      @ws.pong

