o
    ¨Ýjå  ã                   @   s*   d dl Z ddlmZ G dd„ dejƒZdS )é    Né   )Úpacketc                   @   s>   e Zd ZdZdZejZedejfdd„ƒZ	dd„ Z
dd„ ZdS )	ÚMsgPackPacketFNc                 C   s    G d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                   @   s   e Zd ZdZdZdS )z4MsgPackPacket.configure.<locals>.CustomMsgPackPacketN)Ú__name__Ú
__module__Ú__qualname__Údumps_defaultÚext_hook© r
   r
   úR/var/www/html/chatgpt/venv/lib/python3.10/site-packages/socketio/msgpack_packet.pyÚCustomMsgPackPacket   s    r   )r   r   r	   )Úclsr   r	   r   r
   r
   r   Ú	configure
   s   zMsgPackPacket.configurec                 C   s   t j|  ¡ | jjd�S )z#Encode the packet for transmission.)Údefault)ÚmsgpackÚdumpsZ_to_dictÚ	__class__r   )Úselfr
   r
   r   Úencode    s   
ÿzMsgPackPacket.encodec                 C   sB   t j|| jjd�}|d | _| d¡| _| d¡| _|d | _dS )zDecode a transmitted package.)r	   ÚtypeÚdataÚidÚnspN)	r   Úloadsr   r	   Zpacket_typeÚgetr   r   Ú	namespace)r   Zencoded_packetÚdecodedr
   r
   r   Údecode%   s   ÿ
zMsgPackPacket.decode)r   r   r   Zuses_binary_eventsr   r   ÚExtTyper	   Úclassmethodr   r   r   r
   r
   r
   r   r      s    r   )r   Ú r   ZPacketr   r
   r
   r
   r   Ú<module>   s    