Beispiel #1
0
 def __init__(self, **kw):
     super().__init__(**kw)
     self._pending_responses = {}
     self._parser = frame_parser(kind=2, pyparser=True)
     actor = get_actor()
     if actor.is_arbiter():
         self.bind_event('connection_lost', self._connection_lost)
Beispiel #2
0
 def parse_frame(self, websocket, frame):
     parser = frame_parser(kind=1)
     frame = parser.decode(frame)
     wsclient = websocket.cache.wsclient
     websocket.connection.reset_mock()
     msg = _json.loads(frame.body[1:])[0]
     return wsclient.protocol.decode(msg)
Beispiel #3
0
 def parse_frame(self, websocket, frame):
     parser = frame_parser(kind=1)
     frame = parser.decode(frame)
     wsclient = websocket.cache.wsclient
     websocket.connection.reset_mock()
     msg = _json.loads(frame.body[1:])[0]
     return wsclient.protocol.decode(msg)
Beispiel #4
0
def handle_101(response, exc=None):
    '''Websocket upgrade as ``on_headers`` event.'''

    if not exc and response.status_code == 101:
        connection = response.connection
        request = response._request
        handler = request.websocket_handler
        parser = frame_parser(kind=1)
        if not handler:
            handler = WS()
        connection.upgrade(partial(WebSocketClient, response, handler, parser))
        response.finished()
        response.request_again = connection.current_consumer()
Beispiel #5
0
def handle_101(response, exc=None):
    '''Websocket upgrade as ``on_headers`` event.'''

    if response.status_code == 101:
        connection = response.connection
        request = response._request
        handler = request.websocket_handler
        parser = frame_parser(kind=1)
        if not handler:
            handler = WS()
        body = response.recv_body()
        connection.upgrade(partial(WebSocketClient, response, handler, parser))
        response.finished()
        consumer = connection.current_consumer()
        consumer.data_received(body)
        response.request_again = consumer
Beispiel #6
0
def handle_101(response, exc=None):
    """Websocket upgrade as ``on_headers`` event."""

    if response.status_code == 101:
        connection = response.connection
        request = response._request
        handler = request.websocket_handler
        parser = frame_parser(kind=1)
        if not handler:
            handler = WS()
        body = response.recv_body()
        connection.upgrade(partial(WebSocketClient, response, handler, parser))
        response.finished()
        consumer = connection.current_consumer()
        consumer.data_received(body)
        response.request_again = consumer
Beispiel #7
0
 def _factory(self, **params):
     params['pyparser'] = self.pyparser
     return frame_parser(**params)
Beispiel #8
0
 def parser(self, pyparser=False, **kw):
     return frame_parser(**kw)
Beispiel #9
0
 def parser(self, pyparser=True, **kw):
     return frame_parser(pyparser=True, **kw)
Beispiel #10
0
 def _factory(self, **params):
     params['pyparser'] = self.pyparser
     return frame_parser(**params)
Beispiel #11
0
 def parser(self, kind=0):
     return frame_parser(pyparser=True, kind=kind)
Beispiel #12
0
 def parser(self, kind=0):
     return frame_parser(kind=kind)
Beispiel #13
0
 def parser(self, kind=0):
     return frame_parser(pyparser=True, kind=kind)
Beispiel #14
0
 def parser(self, kind=0):
     return frame_parser(kind=kind)
Beispiel #15
0
 def parser(self, pyparser=True, **kw):
     return frame_parser(pyparser=True, **kw)
Beispiel #16
0
 def parser(self, pyparser=False, **kw):
     return frame_parser(**kw)