�
���g� � �L � d dl mZ d dlmZ d dlmZmZmZ G d� d� � ZdS )� )�Event)�Client)�
SocketIOError�TimeoutError�DisconnectedErrorc � � e Zd ZdZeZd� Zi dddddfd�Zed� � � Z ed � � � Z
dd
�Zdd�Zdd
�Z
d� Zd� Zd� ZdS )�SimpleClienta& A Socket.IO client.
This class implements a simple, yet fully compliant Socket.IO web client
with support for websocket and long-polling transports.
The positional and keyword arguments given in the constructor are passed
to the underlying :func:`socketio.Client` object.
c � � || _ || _ d | _ d| _ t � � | _ d| _ t � � | _ g | _ d S )N�/F) �client_args�
client_kwargs�client� namespacer �connected_event� connected�input_event�input_buffer)�self�args�kwargss �f/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/socketio/simple_client.py�__init__zSimpleClient.__init__ sM � ����#���������$�w�w������ �7�7�������� Nr z socket.io� c �X � � � j rt d� � �|� _ g � _ � j � � � � j � j i � j ��� _ � j �
� j �� � � fd�� � }� j �
� j �� � � fd�� � } � j �
� j �� � � fd�� � }
� j � d� j �� � � fd�� � }� j � |||||g||�� � d S )
aL Connect to a Socket.IO server.
:param url: The URL of the Socket.IO server. It can include custom
query string parameters if required by the server. If a
function is provided, the client will invoke it to obtain
the URL each time a connection or reconnection is
attempted.
:param headers: A dictionary with custom headers to send with the
connection request. If a function is provided, the
client will invoke it to obtain the headers dictionary
each time a connection or reconnection is attempted.
:param auth: Authentication data passed to the server with the
connection request, normally a dictionary with one or
more string key/value pairs. If a function is provided,
the client will invoke it to obtain the authentication
data each time a connection or reconnection is attempted.
:param transports: The list of allowed transports. Valid transports
are ``'polling'`` and ``'websocket'``. If not
given, the polling transport is connected first,
then an upgrade to websocket is attempted.
:param namespace: The namespace to connect to as a string. If not
given, the default namespace ``/`` is used.
:param socketio_path: The endpoint where the Socket.IO server is
installed. The default value is appropriate for
most cases.
:param wait_timeout: How long the client should wait for the
connection to be established. The default is 5
seconds.
zAlready connected�r c �H �� d� _ � j � � � d S )NT�r r �set�r s �r �connectz%SimpleClient.connect.<locals>.connectB s% �� �!�D�N�� �$�$�&�&�&�&�&r c �: �� � j � � � d S �N)r �clearr s �r �
disconnectz(SimpleClient.connect.<locals>.disconnectG s �� �� �&�&�(�(�(�(�(r c �H �� d� _ � j � � � d S )NFr r s �r �__disconnect_finalz0SimpleClient.connect.<locals>.__disconnect_finalK s% �� �"�D�N�� �$�$�&�&�&�&�&r �*c �t �� �j � | g|�� � �j � � � d S r# )r �appendr r )�eventr r s �r �on_eventz&SimpleClient.connect.<locals>.on_eventP s; �� ���$�$�e�^�d�^�4�4�4��� � �"�"�"�"�"r )�headers�auth�
transports�
namespaces�
socketio_path�wait_timeoutN)
r �RuntimeErrorr r r r$ �client_classr r
r r+ �onr! )r �urlr- r. r/ r r1 r2 r! r% �_SimpleClient__disconnect_finalr, s ` r r! zSimpleClient.connect s� �� �>