Пример #1
0
class WSClient(WebSocketClient):
    def __init__(self, *args, **kwargs):
        self.client = kwargs.pop('client')
        self.protocol = DDPProtocol(self)
        super(WSClient, self).__init__(*args, **kwargs)

    def connect(self):
        self.sock.settimeout(10)
        rv = super(WSClient, self).connect()
        if self.sock:
            self.sock.settimeout(None)
        return rv

    def opened(self):
        self.protocol.on_open()

    def closed(self, code, reason=None):
        self.protocol.on_close(code, reason)

    def received_message(self, message):
        self.protocol.on_message(message.data.decode('utf8'))

    def on_open(self):
        self.client.on_open()

    def on_message(self, message):
        self.client._recv(message)

    def on_close(self, code, reason=None):
        self.client.on_close(code, reason)
Пример #2
0
class WSClient(WebSocketClient):
    def __init__(self, *args, **kwargs):
        self.client = kwargs.pop('client')
        self.protocol = DDPProtocol(self)
        super(WSClient, self).__init__(*args, **kwargs)

    def connect(self):
        self.sock.settimeout(10)
        rv = super(WSClient, self).connect()
        self.sock.settimeout(None)
        return rv

    def opened(self):
        self.protocol.on_open()

    def closed(self, code, reason=None):
        self.protocol.on_close(code, reason)

    def received_message(self, message):
        self.protocol.on_message(message.data.decode('utf8'))

    def on_open(self):
        self.client.on_open()

    def on_message(self, message):
        self.client._recv(message)

    def on_close(self, code, reason=None):
        self.client.on_close(code, reason)
Пример #3
0
 def __init__(self, *args, **kwargs):
     self.client = kwargs.pop('client')
     self.protocol = DDPProtocol(self)
     super(WSClient, self).__init__(*args, **kwargs)
Пример #4
0
 def __init__(self, *args, **kwargs):
     self.client = kwargs.pop('client')
     self.protocol = DDPProtocol(self)
     super(WSClient, self).__init__(*args, **kwargs)