
    wg%                     d    d dl mZ  G d dej                        Z G d dej                        Zy)   )base_namespacec                   r    e Zd ZdZd Z	 	 ddZ	 	 ddZ	 	 ddZddZddZ	dd	Z
dd
ZddZddZddZy)	Namespacea  Base class for server-side class-based namespaces.

    A class-based namespace is a class that contains all the event handlers
    for a Socket.IO namespace. The event handlers are methods of the class
    with the prefix ``on_``, such as ``on_connect``, ``on_disconnect``,
    ``on_message``, ``on_json``, and so on.

    :param namespace: The Socket.IO namespace to be used with all the event
                      handlers defined in this class. If this argument is
                      omitted, the default namespace is used.
    c                     d|xs dz   }t        | |      r	  t        | |      | S y# t        $ r |dk(  r t        | |      |dd  cY S  w xY wab  Dispatch an event to the proper handler method.

        In the most common usage, this method is not overloaded by subclasses,
        as it performs the routing of events to methods. However, this
        method can be overridden if special dispatching rules are needed, or if
        having a single method that catches all events is desired.
        on_ 
disconnectNhasattrgetattr	TypeErrorselfeventargshandler_names       W/home/mcse/projects/flask/flask-venv/lib/python3.12/site-packages/socketio/namespace.pytrigger_eventzNamespace.trigger_event   p     ,4&2wt\2D99 '  L(6746Sb	BB   '  A	ANc	           
      d    | j                   j                  ||||||xs | j                  ||      S )zEmit a custom event to one or more connected clients.

        The only difference with the :func:`socketio.Server.emit` method is
        that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        )datatoroomskip_sid	namespacecallbackignore_queue)serveremitr   )	r   r   r   r   r   r   r   r   r    s	            r   r"   zNamespace.emit#   s>     {{DRd)1*3*Et~~)1   N 	N    c           	      b    | j                   j                  |||||xs | j                  ||      S )zSend a message to one or more connected clients.

        The only difference with the :func:`socketio.Server.send` method is
        that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        )r   r   r   r   r   r    )r!   sendr   )r   r   r   r   r   r   r   r    s           r   r%   zNamespace.send0   s;     {{$*3*Et~~)1   N 	Nr#   c           	      b    | j                   j                  |||||xs | j                  ||      S )a  Emit a custom event to a client and wait for the response.

        The only difference with the :func:`socketio.Server.call` method is
        that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        )r   r   sidr   timeoutr    )r!   callr   )r   r   r   r   r'   r   r(   r    s           r   r)   zNamespace.call<   s;     {{DRS*3*Et~~(/l   L 	Lr#   c                 Z    | j                   j                  |||xs | j                        S )zEnter a room.

        The only difference with the :func:`socketio.Server.enter_room` method
        is that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        r   )r!   
enter_roomr   r   r'   r   r   s       r   r,   zNamespace.enter_roomH   2     {{%%c4090KT^^ & M 	Mr#   c                 Z    | j                   j                  |||xs | j                        S )zLeave a room.

        The only difference with the :func:`socketio.Server.leave_room` method
        is that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        r+   )r!   
leave_roomr   r-   s       r   r0   zNamespace.leave_roomR   r.   r#   c                 X    | j                   j                  ||xs | j                        S )zClose a room.

        The only difference with the :func:`socketio.Server.close_room` method
        is that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        r+   )r!   
close_roomr   )r   r   r   s      r   r2   zNamespace.close_room\   s0     {{%%d090KT^^ & M 	Mr#   c                 X    | j                   j                  ||xs | j                        S )zReturn the user session for a client.

        The only difference with the :func:`socketio.Server.get_session`
        method is that when the ``namespace`` argument is not given the
        namespace associated with the class is used.
        r+   )r!   get_sessionr   r   r'   r   s      r   r4   zNamespace.get_sessionf   s.     {{&&96 ' 8 	8r#   c                 Z    | j                   j                  |||xs | j                        S )zStore the user session for a client.

        The only difference with the :func:`socketio.Server.save_session`
        method is that when the ``namespace`` argument is not given the
        namespace associated with the class is used.
        r+   )r!   save_sessionr   )r   r'   sessionr   s       r   r7   zNamespace.save_sessionp   s2     {{''I$? ( A 	Ar#   c                 X    | j                   j                  ||xs | j                        S )a  Return the user session for a client with context manager syntax.

        The only difference with the :func:`socketio.Server.session` method is
        that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        r+   )r!   r8   r   r5   s      r   r8   zNamespace.sessionz   s'     {{""3)2Mt~~"NNr#   c                 X    | j                   j                  ||xs | j                        S )zDisconnect a client.

        The only difference with the :func:`socketio.Server.disconnect` method
        is that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        r+   )r!   r
   r   r5   s      r   r
   zNamespace.disconnect   s0     {{%%c090KT^^ & M 	Mr#   )NNNNNNF)NNNNNF)N)__name__
__module____qualname____doc__r   r"   r%   r)   r,   r0   r2   r4   r7   r8   r
    r#   r   r   r      se    
& CG9>N GK).
N CG(-
LMMM8AOMr#   r   c                   4    e Zd ZdZd ZddZddZddZd Zy)	ClientNamespacea  Base class for client-side class-based namespaces.

    A class-based namespace is a class that contains all the event handlers
    for a Socket.IO namespace. The event handlers are methods of the class
    with the prefix ``on_``, such as ``on_connect``, ``on_disconnect``,
    ``on_message``, ``on_json``, and so on.

    :param namespace: The Socket.IO namespace to be used with all the event
                      handlers defined in this class. If this argument is
                      omitted, the default namespace is used.
    c                     d|xs dz   }t        | |      r	  t        | |      | S y# t        $ r |dk(  r t        | |      |dd  cY S  w xY wr   r   r   s       r   r   zClientNamespace.trigger_event   r   r   Nc                 \    | j                   j                  |||xs | j                  |      S )zEmit a custom event to the server.

        The only difference with the :func:`socketio.Client.emit` method is
        that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        )r   r   r   )clientr"   r   )r   r   r   r   r   s        r   r"   zClientNamespace.emit   s3     {{D*3*Et~~)1   3 	3r#   c                 Z    | j                   j                  ||xs | j                  |      S )zSend a message to the server.

        The only difference with the :func:`socketio.Client.send` method is
        that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        )r   r   )rD   r%   r   )r   r   r   r   r   s        r   r%   zClientNamespace.send   s0     {{	0KT^^)1   3 	3r#   c                 \    | j                   j                  |||xs | j                  |      S )a  Emit a custom event to the server and wait for the response.

        The only difference with the :func:`socketio.Client.call` method is
        that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        )r   r   r(   )rD   r)   r   )r   r   r   r   r(   s        r   r)   zClientNamespace.call   s3     {{D*3*Et~~(/   1 	1r#   c                 6    | j                   j                         S )zDisconnect from the server.

        The only difference with the :func:`socketio.Client.disconnect` method
        is that when the ``namespace`` argument is not given the namespace
        associated with the class is used.
        )rD   r
   )r   s    r   r
   zClientNamespace.disconnect   s     {{%%''r#   )NNN)	r;   r<   r=   r>   r   r"   r%   r)   r
   r?   r#   r   rA   rA      s     
&	33	1(r#   rA   N)r	   r   BaseServerNamespacer   BaseClientNamespacerA   r?   r#   r   <module>rJ      s3    GM22 GMTF(n88 F(r#   