�
���g[j � � � d dl mZ d dlmZ d dlZd dlZd dlZd dlZd dlZd dl Z d dl
Z
n
# e$ r dZ
Y nw xY w d dlZn
# e$ r dZY nw xY wddl
mZ ddl
mZ ddl
mZ ddl
mZ ej d � � Z G d
� dej � � ZdS )� )� b64encode)�JSONDecodeErrorN� )�base_client)�
exceptions)�packet)�payloadzengineio.clientc � � e Zd ZdZ dd�Zd� Zd� Zdd�Zd � Zdd�Z d� Z
d
� Zd� Zd� Z
d� Zd� Z dd�Zd� Zd� Zd� Zd� ZdS )�Clienta� An Engine.IO client.
This class implements a fully compliant Engine.IO web client with support
for websocket and long-polling transports.
:param logger: To enable logging set to ``True`` or pass a logger object to
use. To disable logging set to ``False``. The default is
``False``. Note that fatal errors are logged even when
``logger`` is ``False``.
:param json: An alternative json module to use for encoding and decoding
packets. Custom json modules must have ``dumps`` and ``loads``
functions that are compatible with the standard library
versions.
:param request_timeout: A timeout in seconds for requests. The default is
5 seconds.
:param http_session: an initialized ``requests.Session`` object to be used
when sending requests to the server. Use it if you
need to add special client options such as proxy
servers, SSL certificates, custom CA bundle, etc.
:param ssl_verify: ``True`` to verify SSL certificates, or ``False`` to
skip SSL certificate verification, allowing
connections to servers with self signed certificates.
The default is ``True``.
:param handle_sigint: Set to ``True`` to automatically handle disconnection
when the process is interrupted, or to ``False`` to
leave interrupt handling to the calling application.
Interrupt handling can only be enabled when the
client instance is created in the main thread.
:param websocket_extra_options: Dictionary containing additional keyword
arguments passed to
``websocket.create_connection()``.
:param timestamp_requests: If ``True`` a timestamp is added to the query
string of Socket.IO requests as a cache-busting
measure. Set to ``False`` to disable.
N� engine.ioc �L �� | j dk rt d� � �ddg�|�7t |t � � r|g}�fd�|D � � }|st d� � �|p�| _ | � � � | _ t | d| j d z � � ||pi |� � S )
a� Connect to an Engine.IO server.
:param url: The URL of the Engine.IO server. It can include custom
query string parameters if required by the server.
:param headers: A dictionary with custom headers to send with the
connection request.
: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 engineio_path: The endpoint where the Engine.IO server is
installed. The default value is appropriate for
most cases.
Example usage::
eio = engineio.Client()
eio.connect('http://localhost:5000')
�disconnectedz%Client is not in a disconnected state�polling� websocketNc � �� g | ]}|�v �|�� S � r )�.0� transport�valid_transportss ��_/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/engineio/client.py�
<listcomp>z"Client.connect.<locals>.<listcomp>Y s. �� � <� <� <� �&�*:�:�:� $�:�:�:� zNo valid transports provided� _connect_r )�state�
ValueError�
isinstance�str�
transports�create_queue�queue�getattr)�self�url�headersr �
engineio_pathr s @r �connectzClient.connect>