
    !ni                     B    d dl Z ddlmZ  G d dej                        Zy)    N   )packetc                   b    e Zd ZdZdZej                  Zedej                  fd       Z	d Z
d Zy)MsgPackPacketFNc                 @     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y)4MsgPackPacket.configure.<locals>.CustomMsgPackPacketN)__name__
__module____qualname__dumps_defaultext_hook     W/home/homepc/tiktok-worker/venv/lib/python3.12/site-packages/socketio/msgpack_packet.pyCustomMsgPackPacketr	      s     MHr   r   )r   r   r   )clsr   r   r   s       r   	configurezMsgPackPacket.configure
   s(    	- 	 -:)'/$""r   c                 t    t        j                  | j                         | j                  j                        S )z#Encode the packet for transmission.)default)msgpackdumps_to_dict	__class__r   )selfs    r   encodezMsgPackPacket.encode    s*    }}T]]_%)^^%A%AC 	Cr   c                     t        j                  || j                  j                        }|d   | _        |j                  d      | _        |j                  d      | _        |d   | _        y)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%   sW    --)-)@)@B"6?KK'	++d# r   )r
   r   r   uses_binary_eventsr   r   ExtTyper   classmethodr   r   r(   r   r   r   r   r      s<    MH%)GOO # #*C
(r   r   )r    r   Packetr   r   r   r   <module>r.      s     '(FMM '(r   