� ���g�)��t�ddlZddlZddlmZddlmZddlmZejd��ZGd�d��ZdS) �N�)�manager)�base_namespace)�packetzsocketio.serverc��eZdZddgZejjZ dd�Zd�Zdd �Z d �Z d �Z dd �Z dd �Z dd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)� BaseServer�connect� disconnectNF�defaultTc �~�|} | �dd��} | �| | d<|dkrtj|_n |dkrddlm} | j|_n||_|�||j_|| d<d| d <|���di| ��|_ |j � d |j ��|j � d |j ��|j � d |j ��i|_i|_i|_t#��|_i|_t)|t*��s||_n�t.|_|jjt2jkrv|r%|j�t2j��n$|j�t2j��|j�t3j����|�tAj!��}||_ |j �"|��d|_#||_$||_%|pd g|_&|j j'|_'dS)N�engineio_logger�loggerr �msgpackr)�msgpack_packet�jsonF�async_handlersr �messager �/�)(�popr�Packet� packet_class�r� MsgPackPacketr�_engineio_server_class�eio�on�_handle_eio_connect�_handle_eio_message�_handle_eio_disconnect�environ�handlers�namespace_handlers�object� not_handled�_binary_packet� isinstance�boolr�default_logger�level�logging�NOTSET�setLevel�INFO�ERROR� addHandler� StreamHandlerr�Manager� set_server�manager_initializedr�always_connect� namespaces� async_mode) �self�client_managerr� serializerrrr5r6�kwargs�engineio_optionsr rs �d/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/socketio/base_server.py�__init__zBaseServer.__init__s2��"��*�.�.�/@�$�G�G�� � &�)8� �X� &� �� "� "� &� �D� � � �9� $� $� (� (� (� (� (� (� .� <�D� � � *�D� � � �%)�D� � "�'+� �V� $�-2��)�*�0�4�.�.�0�0�D�D�3C�D�D��� �� � �I�t�7�8�8�8� �� � �I�t�7�8�8�8� �� � �L�$�"=�>�>�>��� ��� �"$���!�8�8��� ����&�$�'�'� @� �D�K�K�(�D�K��{� �G�N�2�2��8��K�(�(���6�6�6�6��K�(�(���7�7�7�� �&�&�w�'<�'>�'>�?�?�?� � !�$�_�.�.�N�%�� � � ����%�%�%�#(�� �,���,���$�-������(�-�����c��dS)NFr�r8s r=�is_asyncio_basedzBaseServer.is_asyncio_basedEs���ur?c�@�����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', namespace='/chat') def connect_handler(sid, environ): print('Connection request') if environ['REMOTE_ADDR'] in blacklisted: return False # reject # as a method: def message_handler(sid, msg): print('Received message: ', msg) sio.send(sid, 'response') socket_io.on('message', namespace='/chat', handler=message_handler) The arguments passed to the handler function depend on the event type: - The ``'connect'`` event handler receives the ``sid`` (session ID) for the client and the WSGI environment dictionary as arguments. - The ``'disconnect'`` handler receives the ``sid`` for the client as only argument. - The ``'message'`` handler and handlers for custom event names receive the ``sid`` for the client and the message payload as arguments. 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. rc�N����jvr i�j�<|�j��<|S�N)r")�handler�event� namespacer8s ���r=� set_handlerz"BaseServer.on.<locals>.set_handlerzs2����� �-�-�+-�� �i�(�.5�D�M�)� $�U� +��Nr?Nr)r8rGrFrHrIs`` ` r=rz BaseServer.onHsX�����`�$�� � � � � � � � � �?�� �� �G�����r?c������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���|��SrE)r�__name__)rF�argsr;r8s ���r=rIz%BaseServer.event.<locals>.set_handler�s2���A�w�t�w�w�/�A�$�A�A�A�&�A�A�'�J�J�Jr?)�len�callablerrL)r8rMr;rIs``` r=rGzBaseServer.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�� r?c��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 serverN)r'r�BaseServerNamespace� ValueErrorrB� _set_serverr#rH)r8�namespace_handlers r=�register_namespacezBaseServer.register_namespace�s����+�(�<�>�>� 9��7�8�8� 8� � � � "� "�&7�&H�&H�&J�&J� J� J��J�K�K� K��%�%�d�+�+�+� � �� 1� ;�<�<�<r?c�@�|pd}|j�||��S)z�Return the rooms a client is in. :param sid: Session ID of the client. :param namespace: The Socket.IO namespace for the event. If this argument is omitted the default namespace is used. r)r� get_rooms)r8�sidrHs r=�roomszBaseServer.rooms�s&���$�� ��|�%�%�c�9�5�5�5r?c�p�|j�||pd��}|j�|��S)a_Return the name of the transport used by the client. The two possible values returned by this function are ``'polling'`` and ``'websocket'``. :param sid: The session of the client. :param namespace: The Socket.IO namespace. If this argument is omitted the default namespace is used. r)r�eio_sid_from_sidr� transport�r8rXrH�eio_sids r=r\zBaseServer.transport�s6���,�/�/��Y�5E�#�F�F���x�!�!�'�*�*�*r?c�p�|j�||pd��}|j�|��S)z�Return the WSGI environ dictionary for a client. :param sid: The session of the client. :param namespace: The Socket.IO namespace. If this argument is omitted the default namespace is used. r)rr[r!�getr]s r=� get_environzBaseServer.get_environ�s6���,�/�/��Y�5E�#�F�F���|����(�(�(r?c��d}||jvrT||j|vr|j||}n1||jvr(d|j|vr|j|d}|g|�R}|�dd|jvr[||jdvr|jd|}|g|�R}n2||jvr)d|jdvr|jdd}||g|�R}||fS�N�*)r"�reserved_events)r8rGrHrMrFs r=�_get_event_handlerzBaseServer._get_event_handler�s ���� �� � %� %��� �i�0�0�0��-� �2�5�9����d�2�2�2��4�=��3�3�3��-� �2�3�7���~��~�~�� �?�s�d�m�3�3��� �c�*�*�*��-��,�U�3��!�)�D�)�)����d�2�2�2��4�=��-�-�-��-��,�S�1���y�0�4�0�0����}�r?c�v�d}||jvr |j|}|�d|jvr|jd}|g|�R}||fSrc)r#)r8rHrMrFs r=�_get_namespace_handlerz!BaseServer._get_namespace_handler�s]�� �� ��/� /� /��-�i�8�G� �?�s�d�&=�=�=��-�c�2�G��%��%�%�D���}�r?c��t���rE��NotImplementedErrorrAs r=rzBaseServer._handle_eio_connect���!�#�#�#r?c��t���rErj)r8�datas r=rzBaseServer._handle_eio_messagerlr?c��t���rErjrAs r=r z!BaseServer._handle_eio_disconnectrlr?c� �td���)Nz!Must be implemented in subclassesrjrAs r=rz!BaseServer._engineio_server_class s��!�"E�F�F�Fr?)NFr NTFN)NNrE)rL� __module__� __qualname__re�engineio�Server�reasonr>rBrrGrUrYr\rarfrhrrr rrr?r=rr s$������ �,�/�O� �_� #�F�EN�@E� �3.�3.�3.�3.�j���:�:�:�:�x!�!�!�F��� 6�6�6�6� +� +� +� +�)�)�)�)����4 � � �$�$�$�$�$�$�$�$�$�G�G�G�G�Gr?r) r+rsrrrr� getLoggerr)rrr?r=�<module>rws�����������������������������"��"�#4�5�5��~G�~G�~G�~G�~G�~G�~G�~G�~G�~Gr?
Memory