Python tornado.websocket 模块,WebSocketHandler() 实例源码

我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用tornado.websocket.WebSocketHandler()

项目:board-games-app    作者:sampathweb    | 项目源码 | 文件源码
def on_close(self):
        """Overwrites WebSocketHandler.close.
        Close Game, send message to Paired client that game has ended
        """
        self.send_pair_message(action="end", game_id=self.game_id, result="A")
        self.game_manager.end_game(self.game_id)
项目:server    作者:arrchat    | 项目源码 | 文件源码
def __init__(self, app, request, clients, **kwargs):
        websocket.WebSocketHandler.__init__(self, app, request, **kwargs)
        self.clients = clients
        self.client = None
项目:async-ipython-magic    作者:leriomaggio    | 项目源码 | 文件源码
def __init__(self):
        super(WebSocketConnectionHandler, self).__init__(
            factory=WebSocketHandler)
项目:baselayer    作者:cesium-ml    | 项目源码 | 文件源码
def __init__(self, *args, **kwargs):
        websocket.WebSocketHandler.__init__(self, *args, **kwargs)

        if WebSocket._zmq_stream is None:
            raise RuntimeError("Please install a stream before instantiating "
                               "any websockets")

        self.authenticated = False
        self.auth_failures = 0
        self.max_auth_fails = 3
        self.username = None
项目:django-tornado-websockets    作者:Kocal    | 项目源码 | 文件源码
def test_add_handler_with_tornado_app_instance(self):
        self.assertIsNone(TornadoWrapper.app)
        self.assertListEqual(TornadoWrapper.handlers, [])

        TornadoWrapper.start_app()
        self.assertIsNotNone(TornadoWrapper.app)

        with self.assertRaisesRegexp(AttributeError, "'str' object has no attribute 'name'"):
            TornadoWrapper.add_handler('a string')

        TornadoWrapper.add_handler([('path', WebSocketHandler, {})])
        TornadoWrapper.add_handler(('path2', WebSocketHandler, {}))