Example #1
0
 def pack(data: Object) -> bytes:
     return (
         bytes(8)
         + Long(MsgId())
         + Int(len(data.write()))
         + data.write()
     )
Example #2
0
 def pack(self, data: Object) -> bytes:
     return (
         bytes(8)
         + Long(self.msg_id())
         + Int(len(data.write()))
         + data.write()
     )
Example #3
0
    def recv(self):
        log.debug("RecvThread started")

        while True:
            packet = self.connection.recv()

            if packet is None or (len(packet) == 4
                                  and Int.read(BytesIO(packet)) == -404):
                if self.is_connected.is_set():
                    Thread(target=self.restart, name="RestartThread").start()
                break

            self.recv_queue.put(packet)

        log.debug("RecvThread stopped")
Example #4
0
    def recv(self):
        log.debug("RecvThread started")

        while True:
            packet = self.connection.recv()

            if packet is None or len(packet) == 4:
                if packet:
                    log.warning("Server sent \"{}\"".format(Int.read(BytesIO(packet))))

                if self.is_connected.is_set():
                    Thread(target=self.restart, name="RestartThread").start()
                break

            self.recv_queue.put(packet)

        log.debug("RecvThread stopped")
Example #5
0
    async def recv(self):
        log.info("RecvTask started")

        while True:
            packet = await self.connection.recv()

            if packet is None or len(packet) == 4:
                self.recv_queue.put_nowait(None)

                if packet:
                    log.warning("Server sent \"{}\"".format(Int.read(BytesIO(packet))))

                if self.is_connected.is_set():
                    asyncio.ensure_future(self.restart())

                break

            self.recv_queue.put_nowait(packet)

        log.info("RecvTask stopped")