�
���g� � �P � d dl Z d dlmZ d\ ZZZZZZ Z
g d�Z G d� d� � ZdS )� N)�json)r � � � � � � )�CONNECT�
DISCONNECT�EVENT�ACK�
CONNECT_ERROR�BINARY_EVENT�
BINARY_ACKc �d � e Zd ZdZdZeZedddddfd�Zd� Z d� Z
d� Zd� Zd � Z
d
� Zd� Zd� Zd
� ZdS )�PacketzSocket.IO packet.TNc �v � || _ || _ || _ || _ | j rg|s|�c| � | j � � rI| j t k r
t | _ n,| j t k r
t | _ nt d� � �d| _ g | _ |r| �
|� � pd| _ d S d S )Nz'Packet does not support binary payload.r )�packet_type�data� namespace�id�uses_binary_events�_data_is_binaryr r r
r �
ValueError�attachment_count�attachments�decode)�selfr r r r �binary�encoded_packets �_/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/socketio/packet.py�__init__zPacket.__init__ s� � �&����� �"�������"� L�� L�"�N�t�/C�/C��I�0� 0�N���5�(�(�#/�� � ��!�S�(�(�#-�� � � �!J�K�K�K� !������� E�$(�K�K��$?�$?�$D�1�D�!�!�!� E� E� c �� � t | j � � }| j t k s| j t k r@| � | j � � \ }}|t t
|� � � � dz z
}n | j }d}| j �| j dk r
|| j dz z
}| j �|t | j � � z
}|�|| j �
|d�� � z
}|�|g|z }|S )a Encode the packet for transmission.
If the packet contains binary elements, this function returns a list
of packets where the first is the original packet with placeholders for
the binary components and the remaining ones the binary attachments.
�-N�/�,)r'