mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-26 12:16:28 +01:00
Add decorator for register_packet_listener()
This commit is contained in:
parent
f6f6511788
commit
6d6a592f07
@ -187,6 +187,15 @@ class Connection(object):
|
|||||||
else:
|
else:
|
||||||
self._outgoing_packet_queue.append(packet)
|
self._outgoing_packet_queue.append(packet)
|
||||||
|
|
||||||
|
def listener(self, *packet_types, **kwds):
|
||||||
|
"""
|
||||||
|
Shorthand decorator to register a function as a packet listener.
|
||||||
|
"""
|
||||||
|
def _method_func(method):
|
||||||
|
self.register_packet_listener(method, *packet_types, **kwds)
|
||||||
|
|
||||||
|
return _method_func
|
||||||
|
|
||||||
def register_packet_listener(self, method, *packet_types, **kwds):
|
def register_packet_listener(self, method, *packet_types, **kwds):
|
||||||
"""
|
"""
|
||||||
Registers a listener method which will be notified when a packet of
|
Registers a listener method which will be notified when a packet of
|
||||||
|
Loading…
Reference in New Issue
Block a user