
    i                     @    d dl Z ddlmZ  G d dej                  ZdS )    N   )packetc                   V    e Zd ZdZdZej        Zedej        fd            Z	d Z
d ZdS )MsgPackPacketFNc                 H     G d dt                     }||_        ||_        |S )a  Change the default options for msgpack encoding and decoding.

        :param dumps_default: a function called for objects that cannot be
                              serialized by default msgpack. The function
                              receives one argument, the object to serialize.
                              It should return a serializable object or a
                              ``msgpack.ExtType`` instance.
        :param ext_hook: a function called when a ``msgpack.ExtType`` object is
                         seen during decoding. The function receives two
                         arguments, the code and the data. It should return the
                         decoded object.
        c                       e Zd ZdZdZdS )4MsgPackPacket.configure.<locals>.CustomMsgPackPacketN)__name__
__module____qualname__dumps_defaultext_hook     B/usr/local/lib/python3.11/dist-packages/socketio/msgpack_packet.pyCustomMsgPackPacketr	      s         MHHHr   r   )r   r   r   )clsr   r   r   s       r   	configurezMsgPackPacket.configure
   sF    	 	 	 	 	- 	 	 	 -:)'/$""r   c                 f    t          j        |                                 | j        j                  S )z#Encode the packet for transmission.)default)msgpackdumps_to_dict	__class__r   )selfs    r   encodezMsgPackPacket.encode    s1    }T]]__%)^%AC C C 	Cr   c                     t          j        || j        j                  }|d         | _        |                    d          | _        |                    d          | _        |d         | _        dS )zDecode a transmitted package.)r   typedataidnspN)	r   loadsr   r   packet_typegetr   r    	namespace)r   encoded_packetdecodeds      r   decodezMsgPackPacket.decode%   sf    -)-)@B B B"6?KK''	++d## r   )r
   r   r   uses_binary_eventsr   r   ExtTyper   classmethodr   r   r(   r   r   r   r   r      sl        MH%)GO # # # [#*C C C
( ( ( ( (r   r   )r    r   Packetr   r   r   r   <module>r.      sV          '( '( '( '( '(FM '( '( '( '( '(r   