Exemplo n.º 1
0
class MessageHandler(tornado.websocket.WebSocketHandler):
    def open(self):
        logging.info("Websocket opened")

        self.writer = MessageWriter(self)

    def sendMessage(self, message):
        self.writer.sendMessage(message)

    def on_message(self, message):
        global gameServer
        req = tornado.escape.json_decode(message)
        logging.debug("Message received: %s", req)
        methodName = req["command"]
        if hasattr(gameServer, methodName):
            getattr(gameServer, methodName)(self, req)
        else:
            logging.error("Received unknown command [%s]", methodName)

    def on_close(self):
        logging.info("Websocket closed")
        self.gameServer = None
Exemplo n.º 2
0
    def open(self):
        logging.info("Websocket opened")

        self.writer = MessageWriter(self)
Exemplo n.º 3
0
    def open(self):
        logging.info("Websocket opened")

        self.gameServer = GameServer()
        writer = MessageWriter(self)
        self.gameServer.setWriter(writer)