� ���g� ��L�ddlmZddlmZddlmZmZmZGd�d��ZdS)�)�Event)�Client)� SocketIOError� TimeoutError�DisconnectedErrorc��eZdZdZeZd�Zidddddfd�Zed���Z ed ���Z dd �Z dd �Z dd �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|_dS)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���jrtd���|�_g�_�j����j�ji�j���_ �j � �j����fd���}�j � �j����fd���} �j � �j����fd���} �j � d�j����fd���} �j � |||||g||���d S) aLConnect 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�rc�H��d�_�j���dS)NT�rr�set�rs�r�connectz%SimpleClient.connect.<locals>.connectBs%���!�D�N� � � $� $� &� &� &� &� &rc�:���j���dS�N)r�clearr s�r� disconnectz(SimpleClient.connect.<locals>.disconnectGs��� � � &� &� (� (� (� (� (rc�H��d�_�j���dS)NFrr s�r�__disconnect_finalz0SimpleClient.connect.<locals>.__disconnect_finalKs%���"�D�N� � � $� $� &� &� &� &� &r�*c�t���j�|g|����j���dSr#)r�appendrr)�eventrrs �r�on_eventz&SimpleClient.connect.<locals>.on_eventPs;��� � � $� $�e�^�d�^� 4� 4� 4� � � � � "� "� "� "� "r)�headers�auth� transports� namespaces� socketio_path� wait_timeoutN) r� RuntimeErrorrrrr$� client_classr r rr+�onr!) r�urlr-r.r/rr1r2r!r%�_SimpleClient__disconnect_finalr,s ` rr!zSimpleClient.connects����> �>� 4��2�3�3� 3�"������ ���� � � �'�d�'� � �5�!%�!3�5�5�� � �� � �T�^� � 4� 4� '� '� '� '� 5� 4� '� �� � �T�^� � 4� 4� )� )� )� )� 5� 4� )� �� � �T�^� � 4� 4� '� '� '� '� 5� 4� '� �����t�~�� 6� 6� #� #� #� #� 7� 6� #� � ���C��t�'1�y�k�*7�)5� � 7� 7� 7� 7� 7rc�R�|jr|j�|j��ndS)z�The session ID received from the server. The session ID is not guaranteed to remain constant throughout the life of the connection, as reconnections can cause it to change. N)r�get_sidrr s r�sidzSimpleClient.sidZs(��7;�k�K�t�{�"�"�4�>�2�2�2�t�Krc�,�|jr |jjndS)z�The name of the transport currently in use. The transport is returned as a string and can be one of ``polling`` and ``websocket``. �)r� transportr s rr=zSimpleClient.transportcs��)-� �;�t�{�$�$��;rc��� |j���|jst��� |j�|||j���S#t$rYnwxYw�b)aEmit an event to the server. :param event: The event name. It can be any string. The event names ``'connect'``, ``'message'`` and ``'disconnect'`` are reserved and should not be used. :param data: The data to send to the server. Data can be of type ``str``, ``bytes``, ``list`` or ``dict``. To send multiple arguments, use a tuple where each element is of one of the types indicated above. This method schedules the event to be sent out and returns, without actually waiting for its delivery. In cases where the client needs to ensure that the event was received, :func:`socketio.SimpleClient.call` should be used instead. Tr)r�waitrrr�emitrr)rr+�datas rr@zSimpleClient.emitls{��  � � � %� %� '� '� '��>� *�'�)�)�)� ��{�'�'��t�t�~�'�N�N�N�� � � � ��� ����  s�!A� A �A �<c��� |j���|jst��� |j�|||j|���S#t$rYnwxYw�c)a�Emit an event to the server and wait for a response. This method issues an emit and waits for the server to provide a response or acknowledgement. If the response does not arrive before the timeout, then a ``TimeoutError`` exception is raised. :param event: The event name. It can be any string. The event names ``'connect'``, ``'message'`` and ``'disconnect'`` are reserved and should not be used. :param data: The data to send to the server. Data can be of type ``str``, ``bytes``, ``list`` or ``dict``. To send multiple arguments, use a tuple where each element is of one of the types indicated above. :param timeout: The waiting timeout. If the timeout is reached before the server acknowledges the event, then a ``TimeoutError`` exception is raised. T)r�timeout)rr?rrr�callrr)rr+rArDs rrEzSimpleClient.call�s���$ � � � %� %� '� '� '��>� *�'�)�)�)� ��{�'�'��t�t�~�07�(�9�9�9�� � � � ��� ���� s�"A� A!� A!c�R�|js�|j�|���st���|jst ���|j�|���st���|j���|j��|j�d��S)a�Wait for an event from the server. :param timeout: The waiting timeout. If the timeout is reached before the server acknowledges the event, then a ``TimeoutError`` exception is raised. The return value is a list with the event name as the first element. If the server included arguments with the event, they are returned as additional list elements. )rDr) rrr?rrrrr$�pop)rrDs r�receivezSimpleClient.receive�s����#� %��'�,�,�#�-�%�%� %�"�n�n�$��>� *�'�)�)�)��#�(�(��(�9�9� %�"�n�n�$� � � "� "� $� $� $��#� %�� �$�$�Q�'�'�'rc�f�|jr)|j���d|_d|_dSdS)zDisconnect from the server.NF)rrr%r s rr%zSimpleClient.disconnect�s<�� �>� #� �K� "� "� $� $� $��D�K�"�D�N�N�N� #� #rc��|Sr#�r s r� __enter__zSimpleClient.__enter__�s��� rc�.�|���dSr#)r%)r�exc_type�exc_val�exc_tbs r�__exit__zSimpleClient.__exit__�s�� �������rr#)NrB)�__name__� __module__� __qualname__�__doc__rr4rr!�propertyr:r=r@rErHr%rLrQrKrrr r s����������L����$&�D�T��[�q�=7�=7�=7�=7�~�L�L��X�L��<�<��X�<�����2����8(�(�(�(�,#�#�#��������rr N) � threadingr�socketior�socketio.exceptionsrrrr rKrr�<module>rZs���������������N�N�N�N�N�N�N�N�N�N�|�|�|�|�|�|�|�|�|�|r
Memory