
    i)                     p    S SK r S SKrSSKJr  SSKJr  SSKJr  \ R                  " S5      r " S S5      rg)	    N   )manager)base_namespace)packetzsocketio.serverc                       \ rS rSrSS/r\R                  R                  r   SS jrS r	SS jr
S rS	 rSS
 jrSS jrSS jrS rS rS rS rS rS rSrg)
BaseServer   connect
disconnectNc                     Un	U	R                  SS 5      n
U
b  XS'   US:X  a  [        R                  U l        O$US:X  a  SSKJn  UR                  U l        OX0l        Ub  X@R                  l        XIS'   SU	S	'   U R                  5       " S0 U	D6U l	        U R                  R                  S
U R                  5        U R                  R                  SU R                  5        U R                  R                  SU R                  5        0 U l        0 U l        0 U l        [#        5       U l        0 U l        [)        U[*        5      (       d  X l        O[.        U l        U R,                  R0                  [2        R4                  :X  a  U(       a*  U R,                  R7                  [2        R8                  5        O)U R,                  R7                  [2        R:                  5        U R,                  R=                  [2        R>                  " 5       5        Uc  [@        RB                  " 5       nXl         U R@                  RE                  U 5        SU l#        XPl$        X`l%        U=(       d    S/U l&        U R                  RN                  U l'        g )Nengineio_loggerloggerdefault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   
serializerr   r   r6   r7   kwargsengineio_optionsr   r   s               Q/home/admin/cozy_coffee/venv/lib/python3.13/site-packages/socketio/base_server.py__init__BaseServer.__init__   s    "*../@$G&)8X&" &D9$( . < <D *%)"'+V$-2)*..0D3CDIt778It778L$"="=>"$!8 &$'' K(DK{{  GNN2KK((6KK((7&&w'<'<'>?!$__.N%%#( ,,$-((--    c                     g)NFr   r9   s    r>   is_asyncio_basedBaseServer.is_asyncio_basedE   s    rA   c                 J   ^ ^^ T=(       d    SmUUU 4S jnUc  U$ U" U5        g)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.
r   c                 j   > TTR                   ;  a  0 TR                   T'   U TR                   T   T'   U $ N)r#   )handlerevent	namespacer9   s    r>   set_handler"BaseServer.on.<locals>.set_handlerz   s5    -+-i(.5DMM)$U+NrA   Nr   )r9   rJ   rI   rK   rL   s   `` ` r>   r   BaseServer.onH   s*    ` $		 ?GrA   c                    ^ ^^ [        T5      S:X  aI  [        T5      S:X  a:  [        TS   5      (       a'  T R                  TS   R                  5      " TS   5      $ UUU 4S jnU$ )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)
r   r   c                 P   > TR                   " U R                  /TQ70 TD6" U 5      $ rH   )r   __name__)rI   argsr<   r9   s    r>   rL   %BaseServer.event.<locals>.set_handler   s'    www//A$A&A'JJrA   )lencallabler   rQ   )r9   rR   r<   rL   s   ``` r>   rJ   BaseServer.event   s[    0 t9>c&kQ.8DG3D3D 7747++,T!W55K rA   c                    [        U[        R                  5      (       d  [        S5      eU R	                  5       UR	                  5       :w  a  [        S5      eUR                  U 5        UU R                  UR                  '   g)zRegister a namespace handler object.

:param namespace_handler: An instance of a :class:`Namespace`
                          subclass that handles all the event traffic
                          for a namespace.
zNot a namespace instancez+Not a valid namespace class for this serverN)r(   r   BaseServerNamespace
ValueErrorrD   _set_serverr$   rK   )r9   namespace_handlers     r>   register_namespaceBaseServer.register_namespace   sx     +(<<> >788  "&7&H&H&JJJKK%%d+ 	 1 ; ;<rA   c                 N    U=(       d    SnU R                   R                  X5      $ )zReturn 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)r9   sidrK   s      r>   roomsBaseServer.rooms   s#     $	||%%c55rA   c                     U R                   R                  X=(       d    S5      nU R                  R                  U5      $ )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r9   r`   rK   eio_sids       r>   re   BaseServer.transport   s2     ,,//5E#Fxx!!'**rA   c                     U R                   R                  X=(       d    S5      nU R                  R                  U5      $ )zReturn 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   )r   rd   r"   getrf   s       r>   get_environBaseServer.get_environ   s2     ,,//5E#F||((rA   c                    S nX R                   ;   a_  XR                   U   ;   a  U R                   U   U   nO:XR                  ;  a+  SU R                   U   ;   a  U R                   U   S   nU/UQ7nUcw  SU R                   ;   ag  XR                   S   ;   a  U R                   S   U   nU/UQ7nXC4$ XR                  ;  a+  SU R                   S   ;   a  U R                   S   S   nX/UQ7nXC4$ N*)r#   reserved_events)r9   rJ   rK   rR   rI   s        r>   _get_event_handlerBaseServer._get_event_handler   s     %i00--	2592224==33--	237~~?sdmm3c**--,U3!)D)
 }	 2224==----,S1040}rA   c                     S nXR                   ;   a  U R                   U   nUc%  SU R                   ;   a  U R                   S   nU/UQ7nX24$ rn   )r$   )r9   rK   rR   rI   s       r>   _get_namespace_handler!BaseServer._get_namespace_handler   s\     ///--i8G?sd&=&==--c2G%%D}rA   c                     [        5       erH   NotImplementedErrorrC   s    r>   r   BaseServer._handle_eio_connect       !##rA   c                     [        5       erH   rw   )r9   datas     r>   r    BaseServer._handle_eio_message  rz   rA   c                     [        5       erH   rw   rC   s    r>   r!   !BaseServer._handle_eio_disconnect  rz   rA   c                     [        S5      e)Nz!Must be implemented in subclassesrw   rC   s    r>   r   !BaseServer._engineio_server_class	  s    !"EFFrA   )r'   r6   r   r8   r   r"   r#   r   r   r5   r$   r7   r&   r   )NFr   NTFN)NNrH   )rQ   
__module____qualname____firstlineno__rp   engineioServerreasonr?   rD   r   rJ   r\   ra   re   rk   rq   rt   r   r    r!   r   __static_attributes__r   rA   r>   r   r      sn     ,/O__##FEN@E 3.j:x!F 6+)4$$$GrA   r   )	r,   r   r   r   r   r   	getLoggerr*   r   r   rA   r>   <module>r      s3        ""#45~G ~GrA   