
    i                      D    S SK Jr  S SKJr  S SKJrJrJr   " S S5      rg)    )Event)Client)SocketIOErrorTimeoutErrorDisconnectedErrorc                       \ rS rSrSr\rS r0 SSSSS4S jr\	S	 5       r
\	S
 5       rSS jrSS jrSS jrS rS rS rSrg)SimpleClient   a  A Socket.IO client.

This class implements a simple, yet fully compliant Socket.IO web client
with support for websocket and long-polling transports.

The positional and keyword arguments given in the constructor are passed
to the underlying :func:`socketio.Client` object.
c                     Xl         X l        S U l        SU l        [	        5       U l        SU l        [	        5       U l        / U l        g )N/F)	client_argsclient_kwargsclient	namespacer   connected_event	connectedinput_eventinput_buffer)selfargskwargss      S/home/admin/cozy_coffee/venv/lib/python3.13/site-packages/socketio/simple_client.py__init__SimpleClient.__init__   s?    #$w 7    Nr   z	socket.io   c           
        ^  T R                   (       a  [        S5      eUT l        / T l        T R                  R                  5         T R                  " T R                  0 T R                  D6T l	        T R                  R                  T R                  S9U 4S j5       nT R                  R                  T R                  S9U 4S j5       n	T R                  R                  T R                  S9U 4S j5       n
T R                  R                  ST R                  S9U 4S j5       nT R                  R                  XUXE/UUS9  g	)
at  Connect to a Socket.IO server.

:param url: The URL of the Socket.IO server. It can include custom
            query string parameters if required by the server. If a
            function is provided, the client will invoke it to obtain
            the URL each time a connection or reconnection is
            attempted.
:param headers: A dictionary with custom headers to send with the
                connection request. If a function is provided, the
                client will invoke it to obtain the headers dictionary
                each time a connection or reconnection is attempted.
:param auth: Authentication data passed to the server with the
             connection request, normally a dictionary with one or
             more string key/value pairs. If a function is provided,
             the client will invoke it to obtain the authentication
             data each time a connection or reconnection is attempted.
:param transports: The list of allowed transports. Valid transports
                   are ``'polling'`` and ``'websocket'``. If not
                   given, the polling transport is connected first,
                   then an upgrade to websocket is attempted.
:param namespace: The namespace to connect to as a string. If not
                  given, the default namespace ``/`` is used.
:param socketio_path: The endpoint where the Socket.IO server is
                      installed. The default value is appropriate for
                      most cases.
:param wait_timeout: How long the client should wait for the
                     connection to be established. The default is 5
                     seconds.
zAlready connectedr   c                  H   > ST l         T R                  R                  5         g )NTr   r   setr   s   r   connect%SimpleClient.connect.<locals>.connectB   s    !DN  $$&r   c                  :   > T R                   R                  5         g N)r   clearr"   s   r   
disconnect(SimpleClient.connect.<locals>.disconnectG   s      &&(r   c                  H   > ST l         T R                  R                  5         g )NFr    r"   s   r   __disconnect_final0SimpleClient.connect.<locals>.__disconnect_finalK   s    "DN  $$&r   *c                 v   > TR                   R                  U /UQ5        TR                  R                  5         g r&   )r   appendr   r!   )eventr   r   s     r   on_event&SimpleClient.connect.<locals>.on_eventP   s/    $$e^d^4  "r   )headersauth
transports
namespacessocketio_pathwait_timeoutN)r   RuntimeErrorr   r   r   r'   client_classr   r   r   r0   onr#   )r   urlr3   r4   r5   r   r7   r8   r#   r(   _SimpleClient__disconnect_finalr1   s   `           r   r#   SimpleClient.connect   s1   > >>233" ''5!%!3!35 
		T^^		4	' 
5	' 
		T^^		4	) 
5	) 
		T^^		4	' 
5	' 
t~~	6	# 
7	# 	Ct'1k*7)5 	 	7r   c                 r    U R                   (       a%  U R                   R                  U R                  5      $ S$ )zThe session ID received from the server.

The session ID is not guaranteed to remain constant throughout the life
of the connection, as reconnections can cause it to change.
N)r   get_sidr   r"   s    r   sidSimpleClient.sidZ   s(     7;kkt{{""4>>2KtKr   c                 \    U R                   (       a  U R                   R                  5       $ S$ )zThe name of the transport currently in use.

The transport is returned as a string and can be one of ``polling``
and ``websocket``.
 )r   	transportr"   s    r   rE   SimpleClient.transportc   s"     +/++t{{$$&=2=r   c                      U R                   R                  5         U R                  (       d
  [        5       e U R                  R                  XU R                  S9$ ! [         a     Of = fMl  )a  Emit an event to the server.

:param event: The event name. It can be any string. The event names
              ``'connect'``, ``'message'`` and ``'disconnect'`` are
              reserved and should not be used.
:param data: The data to send to the server. Data can be of
             type ``str``, ``bytes``, ``list`` or ``dict``. To send
             multiple arguments, use a tuple where each element is of
             one of the types indicated above.

This method schedules the event to be sent out and returns, without
actually waiting for its delivery. In cases where the client needs to
ensure that the event was received, :func:`socketio.SimpleClient.call`
should be used instead.
r   )r   waitr   r   r   emitr   r   )r   r0   datas      r   rI   SimpleClient.emitl   sc        %%'>>')){{''t~~'NN   s   #A 
A)(A)c                      U R                   R                  5         U R                  (       d
  [        5       e U R                  R                  XU R                  US9$ ! [         a    e [         a     Of = fMw  )aX  Emit an event to the server and wait for a response.

This method issues an emit and waits for the server to provide a
response or acknowledgement. If the response does not arrive before the
timeout, then a ``TimeoutError`` exception is raised.

:param event: The event name. It can be any string. The event names
              ``'connect'``, ``'message'`` and ``'disconnect'`` are
              reserved and should not be used.
:param data: The data to send to the server. Data can be of
             type ``str``, ``bytes``, ``list`` or ``dict``. To send
             multiple arguments, use a tuple where each element is of
             one of the types indicated above.
:param timeout: The waiting timeout. If the timeout is reached before
                the server acknowledges the event, then a
                ``TimeoutError`` exception is raised.
)r   timeout)	r   rH   r   r   r   callr   r   r   )r   r0   rJ   rM   s       r   rN   SimpleClient.call   sw    $   %%'>>')){{''t~~07 ( 9 9    s   $A A43A4c                    U R                   (       d  U R                  R                  US9(       d
  [        5       eU R                  (       d
  [        5       eU R                  R                  US9(       d
  [        5       eU R                  R                  5         U R                   (       d  M  U R                   R                  S5      $ )a  Wait for an event from the server.

:param timeout: The waiting timeout. If the timeout is reached before
                the server acknowledges the event, then a
                ``TimeoutError`` exception is raised.

The return value is a list with the event name as the first element. If
the server included arguments with the event, they are returned as
additional list elements.
)rM   r   )	r   r   rH   r   r   r   r   r'   pop)r   rM   s     r   receiveSimpleClient.receive   s     ##'',,# - %"n$>>'))##(((9"n$""$ ###   $$Q''r   c                 x    U R                   (       a)  U R                  R                  5         SU l        SU l         gg)zDisconnect from the server.NF)r   r   r(   r"   s    r   r(   SimpleClient.disconnect   s,    >>KK""$DK"DN r   c                     U $ r&    r"   s    r   	__enter__SimpleClient.__enter__   s    r   c                 $    U R                  5         g r&   )r(   )r   exc_typeexc_valexc_tbs       r   __exit__SimpleClient.__exit__   s    r   )r   r   r   r   r   r   r   r   r&   )N<   )__name__
__module____qualname____firstlineno____doc__r   r:   r   r#   propertyrA   rE   rI   rN   rR   r(   rX   r^   __static_attributes__rW   r   r   r	   r	      sq     L $&DT[q=7~ L L > >2<(,#r   r	   N)		threadingr   socketior   socketio.exceptionsr   r   r   r	   rW   r   r   <module>rk      s      N N~ ~r   