� ���gu-���ddlZddlZddlZddlZddlZddlmZddlmZejd��Z gZ d�Z da Gd�d��Z dS) �N�)�base_namespace)�packetzsocketio.clientc���tdd�D]}|j����tt��rt ||��St j||��S)z�SIGINT handler. Notify any clients that are in a reconnect loop to abort. Other disconnection tasks are handled at the engine.io level. N)�reconnecting_clients�_reconnect_abort�set�callable�original_signal_handler�signal�default_int_handler)�sig�frame�clients �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/socketio/base_client.py�signal_handlerrsj�� '�q�q�q�)�&�&����#�#�%�%�%�%��'�(�(�6�&�s�E�2�2�2��)�#�u�5�5�5�c��eZdZgd�ZejjZ dd �Zd �Zdd �Z d �Z d�Z dd�Z d�Z d�Zd�Zd�Zd�Zd�Zd�Zd�Zd S)� BaseClient)�connect� connect_error� disconnect�__disconnect_finalTrr���?F�defaultNc  �2�| rSt�Ltj��tj��kr$t jtjt ��a||_||_||_ ||_ ||_ | |_ | } | | d<| � dd��} | �| | d<|dkrtj|_n |dkrddlm} | j|_n||_|�||j_|| d<|���d i| ��|_|j�d |j��|j�d |j��|j�d |j��t7|t8��s||_n�t<|_|jjt@j!krv|r%|j�"t@j#��n$|j�"t@j$��|j�%tAj&����d|_'d|_(d|_)d|_*g|_+d|_,d|_-d |_.i|_/i|_0i|_1i|_2d|_3d|_4d|_5d|_6dS)N� handle_sigint�engineio_logger�loggerr�msgpackr)�msgpack_packet�jsonr�messagerF�)7r � threading�current_thread� main_threadr �SIGINTr� reconnection�reconnection_attempts�reconnection_delay�reconnection_delay_max�randomization_factorr�popr�Packet� packet_class�r"� MsgPackPacketr#�_engineio_client_class�eio�on�_handle_eio_connect�_handle_eio_message�_handle_eio_disconnect� isinstance�boolr �default_logger�level�logging�NOTSET�setLevel�INFO�ERROR� addHandler� StreamHandler�connection_url�connection_headers�connection_auth�connection_transports�connection_namespaces� socketio_path�sid� connected� namespaces�handlers�namespace_handlers� callbacks�_binary_packet�_connect_event�_reconnect_taskr)�selfr*r+r,r-r.r � serializerr#r�kwargs�engineio_optionsrr"s r�__init__zBaseClient.__init__&s��� � D�4�<��(�*�*�i�.C�.E�.E�E�E�&,�m�F�M�4B�'D�'D� #�(���%:��"�"4���&<��#�$8��!�*���!��,9���)�*�.�.�/@�$�G�G�� � &�)8� �X� &� �� "� "� &� �D� � � �9� $� $� (� (� (� (� (� (� .� <�D� � � *�D� � � �%)�D� � "�'+� �V� $�0�4�.�.�0�0�D�D�3C�D�D��� �� � �I�t�7�8�8�8� �� � �I�t�7�8�8�8� �� � �L�$�"=�>�>�>��&�$�'�'� @� �D�K�K�(�D�K��{� �G�N�2�2��8��K�(�(���6�6�6�6��K�(�(���7�7�7�� �&�&�w�'<�'>�'>�?�?�?�"���"&���#���%)��"�%'��"�!�������������� �"$������"���"���#��� $����rc��dS)NFr%�rTs r�is_asyncio_basedzBaseClient.is_asyncio_basedhs���urc�@�����pd����fd�}|�|S||��dS)a�Register an event handler. :param event: The event name. It can be any string. The event names ``'connect'``, ``'message'`` and ``'disconnect'`` are reserved and should not be used. The ``'*'`` event name can be used to define a catch-all event handler. :param handler: The function that should be invoked to handle the event. When this parameter is not given, the method acts as a decorator for the handler function. :param namespace: The Socket.IO namespace for the event. If this argument is omitted the handler is associated with the default namespace. A catch-all namespace can be defined by passing ``'*'`` as the namespace. Example usage:: # as a decorator: @sio.on('connect') def connect_handler(): print('Connected!') # as a method: def message_handler(msg): print('Received message: ', msg) sio.send( 'response') sio.on('message', message_handler) The arguments passed to the handler function depend on the event type: - The ``'connect'`` event handler does not take arguments. - The ``'disconnect'`` event handler does not take arguments. - The ``'message'`` handler and handlers for custom event names receive the message payload as only argument. Any values returned from a message handler will be passed to the client's acknowledgement callback function if it exists. - A catch-all event handler receives the event name as first argument, followed by any arguments specific to the event. - A catch-all namespace event handler receives the namespace as first argument, followed by any arguments specific to the event. - A combined catch-all namespace and catch-all event handler receives the event name as first argument and the namespace as second argument, followed by any arguments specific to the event. �/c�N����jvr i�j�<|�j��<|S�N)rN)�handler�event� namespacerTs ���r� set_handlerz"BaseClient.on.<locals>.set_handler�s2����� �-�-�+-�� �i�(�.5�D�M�)� $�U� +��NrNr%)rTrar`rbrcs`` ` rr6z BaseClient.onksX�����X�$�� � � � � � � � � �?�� �� �G�����rc������t���dkrWt���dkrDt�d��r/���dj���d��S���fd�}|S)a�Decorator to register an event handler. This is a simplified version of the ``on()`` method that takes the event name from the decorated function. Example usage:: @sio.event def my_event(data): print('Received data: ', data) The above example is equivalent to:: @sio.on('my_event') def my_event(data): print('Received data: ', data) A custom namespace can be given as an argument to the decorator:: @sio.event(namespace='/test') def my_event(data): print('Received data: ', data) rrc�B���j|jg��Ri���|��Sr_)r6�__name__)r`�argsrVrTs ���rrcz%BaseClient.event.<locals>.set_handler�s2���A�w�t�w�w�/�A�$�A�A�A�&�A�A�'�J�J�Jr)�lenr r6rf)rTrgrVrcs``` rrazBaseClient.event�s������0 �t�9�9��>�>�c�&�k�k�Q�.�.�8�D��G�3D�3D�.�-�4�7�7�4��7�+�,�,�T�!�W�5�5� 5� K� K� K� K� K� K� K�� rc��t|tj��std���|���|���krtd���|�|��||j|j<dS)z�Register a namespace handler object. :param namespace_handler: An instance of a :class:`Namespace` subclass that handles all the event traffic for a namespace. zNot a namespace instancez+Not a valid namespace class for this clientN)r:r�BaseClientNamespace� ValueErrorr[� _set_clientrOrb)rT�namespace_handlers r�register_namespacezBaseClient.register_namespace�s����+�(�<�>�>� 9��7�8�8� 8� � � � "� "�&7�&H�&H�&J�&J� J� J��J�K�K� K��%�%�d�+�+�+� � �� 1� ;�<�<�<rc�:�|j�|pd��S)aReturn the ``sid`` associated with a connection. :param namespace: The Socket.IO namespace. If this argument is omitted the handler is associated with the default namespace. Note that unlike previous versions, the current version of the Socket.IO protocol uses different ``sid`` values per namespace. This method returns the ``sid`` for the requested namespace as a string. r])rM�get)rTrbs r�get_sidzBaseClient.get_sid�s����"�"�9�#3��4�4�4rc�4�|j���S)z�Return the name of the transport used by the client. The two possible values returned by this function are ``'polling'`` and ``'websocket'``. )r5� transportrZs rrszBaseClient.transport�s�� �x�!�!�#�#�#rc��d}||jvrU||j|vr|j||}n�||jvr(d|j|vr|j|d}|g|�R}ndd|jvr[||jdvr|jd|}|g|�R}n2||jvr)d|jdvr|jdd}||g|�R}||fS�N�*)rN�reserved_events)rTrarbrgr`s r�_get_event_handlerzBaseClient._get_event_handler�s ���� �� � %� %��� �i�0�0�0��-� �2�5�9����d�2�2�2��4�=��3�3�3��-� �2�3�7���~��~�~��� �D�M� !� !��� �c�*�*�*��-��,�U�3��!�)�D�)�)����d�2�2�2��4�=��-�-�-��-��,�S�1���y�0�4�0�0����}�rc�t�d}||jvr|j|}nd|jvr|jd}|g|�R}||fSru)rO)rTrbrgr`s r�_get_namespace_handlerz!BaseClient._get_namespace_handlers[�� �� ��/� /� /��-�i�8�G�G� �D�+� +� +��-�c�2�G��%��%�%�D���}�rc��|pd}||jvrdtjd��i|j|<t|j|d��}||j||<|S)z/Generate a unique identifier for an ACK packet.r]rr)rP� itertools�count�next)rTrb�callback�ids r�_generate_ack_idzBaseClient._generate_ack_idsc���$�� � �D�N� *� *�)*�I�O�A�,>�,>�(?�D�N�9� %� �$�.��+�A�.� /� /��(0���y�!�"�%�� rc��t���r_��NotImplementedErrorrZs rr7zBaseClient._handle_eio_connect���!�#�#�#rc��t���r_r�)rT�datas rr8zBaseClient._handle_eio_message r�rc��t���r_r�)rT�reasons rr9z!BaseClient._handle_eio_disconnect#r�rc��t���r_r�rZs rr4z!BaseClient._engineio_client_class&r�r) TrrrrFrNT)NNr_)rf� __module__� __qualname__rw�engineio�Clientr�rXr[r6rarnrqrsrxrzr�r7r8r9r4r%rrrr!s#������-�-�-�O� �_� #�F�@A�>?�DM�*.�@%�@%�@%�@%�D���6�6�6�6�p!�!�!�F��� 5� 5� 5� 5�$�$�$����4 � � ����$�$�$�$�$�$�$�$�$�$�$�$�$�$rr)r|r>r r&r�r2rr� getLoggerr<rrr rr%rr�<module>r�s����������� � � � ���������������������"��"�#4�5�5���� 6� 6� 6���F$�F$�F$�F$�F$�F$�F$�F$�F$�F$r
Memory