|
|
@ -1,6 +1,9 @@ |
|
|
|
|
|
import logging |
|
|
import msgpack |
|
|
import msgpack |
|
|
from . import packet |
|
|
from . import packet |
|
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger('socketio') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MsgPackPacket(packet.Packet): |
|
|
class MsgPackPacket(packet.Packet): |
|
|
uses_binary_events = False |
|
|
uses_binary_events = False |
|
|
@ -28,10 +31,24 @@ class MsgPackPacket(packet.Packet): |
|
|
dumps_default = kwargs.pop('dumps_default', None) |
|
|
dumps_default = kwargs.pop('dumps_default', None) |
|
|
ext_hook = kwargs.pop('ext_hook', msgpack.ExtType) |
|
|
ext_hook = kwargs.pop('ext_hook', msgpack.ExtType) |
|
|
|
|
|
|
|
|
|
|
|
if args: |
|
|
|
|
|
logger.warning( |
|
|
|
|
|
'Some positional arguments to MsgPackPacket.configure() are ' |
|
|
|
|
|
'not used: %s', |
|
|
|
|
|
args, |
|
|
|
|
|
) |
|
|
|
|
|
if kwargs: |
|
|
|
|
|
logger.warning( |
|
|
|
|
|
'Some keyword arguments to MsgPackPacket.configure() are ' |
|
|
|
|
|
'not used: %s', |
|
|
|
|
|
kwargs, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
class ConfiguredMsgPackPacket(cls): |
|
|
class ConfiguredMsgPackPacket(cls): |
|
|
def _encode(self, **kwargs): |
|
|
def _encode(self, **kwargs): |
|
|
kwargs.setdefault('default', dumps_default) |
|
|
kwargs.setdefault('default', dumps_default) |
|
|
return super()._encode(**kwargs) |
|
|
return super()._encode(**kwargs) |
|
|
|
|
|
|
|
|
def _decode(self, encoded_packet, **kwargs): |
|
|
def _decode(self, encoded_packet, **kwargs): |
|
|
kwargs.setdefault('ext_hook', ext_hook) |
|
|
kwargs.setdefault('ext_hook', ext_hook) |
|
|
return super()._decode(encoded_packet, **kwargs) |
|
|
return super()._decode(encoded_packet, **kwargs) |
|
|
|