This commit is contained in:
2025-10-02 19:22:48 +01:00
parent b59e1dab99
commit 209c690413
2179 changed files with 340188 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
import msgpack
from . import packet
class MsgPackPacket(packet.Packet):
uses_binary_events = False
def encode(self):
"""Encode the packet for transmission."""
return msgpack.dumps(self._to_dict())
def decode(self, encoded_packet):
"""Decode a transmitted package."""
decoded = msgpack.loads(encoded_packet)
self.packet_type = decoded['type']
self.data = decoded.get('data')
self.id = decoded.get('id')
self.namespace = decoded['nsp']