     @treatCommand(json)
 
 
-  onMessage: (msg) ->
-    data = msg.data
+  onMessage: (data) ->
     @emit 'alive'
     return @treatHeartbeat(data) if @isHeartbeat(data)
     @log "> #{data}"

    @whichServer roomId, (host, port) ->
      url  = "ws://#{host}:#{port}/socket.io/websocket"
      @ws = new WebSocket(url)
      @ws.onmessage = @onMessage.bind(@)
      @ws.onerror = @disconnect.bind(@)
      @ws.onclose = @onClose.bind(@)

  whichServer: (roomid, callback) ->
    options =


  roomRegister: (roomId, callback) ->
    if @ws
      @ws.removeAllListeners 'message'
      @ws.removeAllListeners 'wserror'
      @ws.removeAllListeners 'close'
      @ws.close()
    @callback = ->
      rq = api: 'room.register', roomid: roomId
