示例#1
0
文件: route.py 项目: samholt/sockjs
    def websocket(self, request):
        # session
        sid = '%0.9d' % random.randint(1, 2147483647)
        session = self.manager.get(sid, True, request=request)

        transport = RawWebSocketTransport(self.manager, session, request)
        try:
            return (yield from transport.process())
        except asyncio.CancelledError:
            raise
        except web.HTTPException as exc:
            return exc
示例#2
0
    def websocket(self, request):
        # session
        sid = '%0.9d' % random.randint(1, 2147483647)
        session = self.manager.get(sid, True, request=request)

        # websocket
        if hdrs.ORIGIN in request.headers:
            return web.HTTPNotFound()

        transport = RawWebSocketTransport(self.manager, session, request)
        try:
            return (yield from transport.process())
        except asyncio.CancelledError:
            raise
        except web.HTTPException as exc:
            return exc
 def maker(method='GET', path='/', query_params={}):
     manager = mock.Mock()
     session = mock.Mock()
     session._remote_closed = make_fut(1)
     session._wait = make_fut((FRAME_CLOSE, ''))
     request = make_request(method, path, query_params=query_params)
     request.app.freeze()
     return RawWebSocketTransport(manager, session, request)