
    i-                         S SK r S SKrS SKrS SKrS SKrSSKJr  SSKJr  \R                  " S5      r	/ r
S rSq " S S5      rg)	    N   )base_namespace)packetzsocketio.clientc                     [         SS  H  nUR                  R                  5         M     [        [        5      (       a  [	        X5      $ [
        R                  " X5      $ )zSIGINT 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      Q/home/admin/cozy_coffee/venv/lib/python3.13/site-packages/socketio/base_client.pysignal_handlerr      sO     'q)##% *'((&s22 ))#55    c                       \ rS rSr/ SQr\R                  R                  r    SS jrS r	SS jr
S rS rSS	 jrS
 rS rS rS rS rS rS rS rSrg)
BaseClient!   )connectconnect_error
disconnect__disconnect_finalNc
                    U	(       a\  [         cU  [        R                  " 5       [        R                  " 5       :X  a)  [        R                  " [        R
                  [        5      q Xl        X l        X0l	        X@l
        XPl        Xl        U
nXS'   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Xpl        Ub  XR                   l        XS'   U R+                  5       " S0 UD6U l        U R,                  R/                  S	U R0                  5        U R,                  R/                  S
U R2                  5        U R,                  R/                  SU R4                  5        [7        U[8        5      (       d  X`l        O[<        U l        U R:                  R>                  [@        RB                  :X  a  U(       a*  U R:                  RE                  [@        RF                  5        O)U R:                  RE                  [@        RH                  5        U R:                  RK                  [@        RL                  " 5       5        S U l'        S U l(        S U l)        S U l*        / U l+        S U l,        S U l-        SU l.        0 U l/        / U l0        0 U l1        0 U l2        0 U l3        S U l4        S U l5        S U l6        S U l7        g )Nhandle_sigintengineio_loggerloggerdefaultmsgpackr   )msgpack_packetjsonr   messager   F )8r   	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failed_namespaceshandlersnamespace_handlers	callbacks_binary_packet_connect_event_reconnect_taskr   )selfr)   r*   r+   r,   r-   r   
serializerr"   r   kwargsengineio_optionsr   r!   s                 r   __init__BaseClient.__init__&   s=   
 4<((*i.C.C.EE&,mmFMM4B'D#(%:""4&<#$8!*!,9)*../@$G&)8X&" &D9$( . < <D *%)"'+V$..0D3CDIt778It778L$"="=>&$'' K(DK{{  GNN2KK((6KK((7&&w'<'<'>?""&#%)"%'"!!#"$""# $r   c                     g)NFr$   rT   s    r   is_asyncio_basedBaseClient.is_asyncio_basedi   s    r   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')
    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                 j   > TTR                   ;  a  0 TR                   T'   U TR                   T   T'   U $ N)rN   )handlerevent	namespacerT   s    r   set_handler"BaseClient.on.<locals>.set_handler   s5    -+-i(.5DMM)$U+Nr   Nr$   )rT   rc   rb   rd   re   s   `` ` r   r5   BaseClient.onl   s*    X $		 ?Gr   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      $ ra   )r5   __name__)rb   argsrV   rT   s    r   re   %BaseClient.event.<locals>.set_handler   s'    www//A$A&A'JJr   )lenr
   r5   rj   )rT   rk   rV   re   s   ``` r   rc   BaseClient.event   s[    0 t9>c&kQ.8DG3D3D 7747++,T!W55K r   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 clientN)r9   r   BaseClientNamespace
ValueErrorr\   _set_clientrO   rd   )rT   namespace_handlers     r   register_namespaceBaseClient.register_namespace   sx     +(<<> >788  "&7&H&H&JJJKK%%d+ 	 1 ; ;<r   c                 J    U R                   R                  U=(       d    S5      $ )a  Return 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_   )rL   get)rT   rd   s     r   get_sidBaseClient.get_sid   s     ""9#344r   c                 6    U R                   R                  5       $ )zReturn the name of the transport used by the client.

The two possible values returned by this function are ``'polling'``
and ``'websocket'``.
)r4   	transportr[   s    r   r{   BaseClient.transport   s     xx!!##r   c                    S nX R                   ;   ad  XR                   U   ;   a  U R                   U   U   nXC4$ XR                  ;  a+  SU R                   U   ;   a  U R                   U   S   nU/UQ7nXC4$ 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*)rN   reserved_events)rT   rc   rd   rk   rb   s        r   _get_event_handlerBaseClient._get_event_handler   s    %i00--	259 } 2224==33--	237~~ } DMM!c**--,U3!)D)
 }	 2224==----,S1040}r   c                     S nXR                   ;   a  U R                   U   nX24$ SU R                   ;   a  U R                   S   nU/UQ7nX24$ r~   )rO   )rT   rd   rk   rb   s       r   _get_namespace_handler!BaseClient._get_namespace_handler  sd     ///--i8G } D+++--c2G%%D}r   c                     U=(       d    SnXR                   ;  a%  S[        R                  " S5      0U R                   U'   [        U R                   U   S   5      nX R                   U   U'   U$ )z/Generate a unique identifier for an ACK packet.r_   r   r   )rP   	itertoolscountnext)rT   rd   callbackids       r   _generate_ack_idBaseClient._generate_ack_id  s`    $	NN*)*IOOA,>(?DNN9%$..+A./(0y!"%	r   c                     [        5       era   NotImplementedErrorr[   s    r   r6   BaseClient._handle_eio_connect      !##r   c                     [        5       era   r   )rT   datas     r   r7   BaseClient._handle_eio_message!  r   r   c                     [        5       era   r   )rT   reasons     r   r8   !BaseClient._handle_eio_disconnect$  r   r   c                     [        5       era   r   r[   s    r   r3   !BaseClient._engineio_client_class'  r   r   )rQ   rR   r   rS   rP   rK   rF   rE   rH   rG   rD   r4   rM   r   rN   r   rO   rL   r0   r-   r)   r*   r+   r,   rJ   rI   )	Tr   r      g      ?Fr   NT)NNra   )rj   
__module____qualname____firstlineno__r   engineioClientr   rX   r\   r5   rc   rt   rx   r{   r   r   r   r6   r7   r8   r3   __static_attributes__r$   r   r   r   r   !   sn    -O__##F@A>?DM*.A%F6p!F 5$4$$$$r   r   )r   r=   r   r%   r   r1   r   r   	getLoggerr;   r   r   r   r   r$   r   r   <module>r      sJ          ""#45 6  G$ G$r   