fix for on_packet
This commit is contained in:
parent
cd402f668a
commit
54f1c1d760
1 changed files with 4 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue