From 54f1c1d760f809fcbd31471334bc54083ef29253 Mon Sep 17 00:00:00 2001 From: alemidev Date: Wed, 17 Nov 2021 17:09:14 +0100 Subject: [PATCH] fix for on_packet --- aiocraft/client.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/aiocraft/client.py b/aiocraft/client.py index 87f4ad8..6bb58ac 100644 --- a/aiocraft/client.py +++ b/aiocraft/client.py @@ -76,18 +76,11 @@ class Client: def connected(self) -> bool: return self.started and self.dispatcher.connected - def on(self, hook): + def on_packet(self, packet:Type[Packet], *args) -> Callable: # receive *args for retro compatibility def wrapper(fun): - pass # TODO - return wrapper - - def on_packet(self, packet:Type[Packet], state:ConnectionState) -> Callable: - def wrapper(fun): - if state not in self._packet_callbacks: - self._packet_callbacks[state] = {} - if packet not in self._packet_callbacks[state]: - self._packet_callbacks[state][packet] = [] - self._packet_callbacks[state][packet].append(fun) + if packet not in self._packet_callbacks: + self._packet_callbacks[packet] = [] + self._packet_callbacks[packet].append(fun) return fun return wrapper