diff --git a/client.py b/client.py index b6f43ba..e4164a2 100644 --- a/client.py +++ b/client.py @@ -67,7 +67,7 @@ class Client(ClientBase): if not self._channels: return - await self.send_packet(iPacket(SendOps.CHARLIST_REQUEST)) + await self.send_packet(oPacket(SendOps.CHARLIST_REQUEST)) return world_name = ipkt.decode_string() diff --git a/client_base.py b/client_base.py index 9727025..d299396 100644 --- a/client_base.py +++ b/client_base.py @@ -120,32 +120,32 @@ class ClientBase: else: nbytes = -1 - await sleep(0.5) + buf = bytearray(self._buff)[4:length + 4][:] - async with self._lock: - buf = bytearray(self._buff)[4:length + 4][:] + print(length, len(buf)) - if length == len(buf): - buf = MapleAes.transform(buf, self._recv_iv) - buf = decrypt_transform(buf) - packet = iPacket(buf) + if length == len(buf): + buf = MapleAes.transform(buf, self._recv_iv) + buf = decrypt_transform(buf) + packet = iPacket(buf) - print(f"Received packet: {packet.to_string()}") + print(f"Received packet: {packet.to_string()}") - self._buff = bytearray() + self._buff = bytearray() - self.handle_packet(packet) + self.handle_packet(packet) def handle_packet(self, packet): coro = None - for packet_handler in self._packet_handlers: - if packet_handler.op_code == packet.op_code: - coro = packet_handler.callback + for pkt_hndl in self._packet_handlers: + print(f"handler: {pkt_hndl.op_code} | packet: {packet.op_code}") + if int(pkt_hndl.op_code) == int(packet.op_code): + coro = pkt_hndl.callback break - else: - print(f"Unhandled packet: {packet.op_code}") - return + else: + print(f"Unhandled packet: {packet.op_code}") + return if not coro: raise AttributeError