You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
bazarr/libs/socketio/msgpack_packet.py

19 lines
514 B

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']