
    i                         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\R                  5      r	g)	    N   )base_server)
exceptions)packetzsocketio.serverc                       \ rS rSrSr  S S jr  S!S jr  S"S jrS#S jrS#S jr	S#S	 jr
S#S
 jrS#S jrS#S jrS$S jrS rS rS rS%S jr   S&S jrS 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)'Server   aB  A Socket.IO server.

This class implements a fully compliant Socket.IO web server with support
for websocket and long-polling transports.

:param client_manager: The client manager instance that will manage the
                       client list. When this is omitted, the client list
                       is stored in an in-memory structure, so the use of
                       multiple connected servers is not possible.
:param logger: To enable logging set to ``True`` or pass a logger object to
               use. To disable logging set to ``False``. The default is
               ``False``. Note that fatal errors are logged even when
               ``logger`` is ``False``.
:param serializer: The serialization method to use when transmitting
                   packets. Valid values are ``'default'``, ``'pickle'``,
                   ``'msgpack'`` and ``'cbor'``. Alternatively, a subclass
                   of the :class:`Packet` class with custom implementations
                   of the ``encode()`` and ``decode()`` methods can be
                   provided. Client and server must use compatible
                   serializers.
:param json: An alternative JSON module to use for encoding and decoding
             packets. Custom json modules must have ``dumps`` and ``loads``
             functions that are compatible with the standard library
             versions. This is a process-wide setting, all instantiated
             servers and clients must use the same JSON module.
:param async_handlers: If set to ``True``, event handlers for a client are
                       executed in separate threads. To run handlers for a
                       client synchronously, set to ``False``. The default
                       is ``True``.
:param always_connect: When set to ``False``, new connections are
                       provisory until the connect handler returns
                       something other than ``False``, at which point they
                       are accepted. When set to ``True``, connections are
                       immediately accepted, and then if the connect
                       handler returns ``False`` a disconnect is issued.
                       Set to ``True`` if you need to emit events from the
                       connect handler and your client is confused when it
                       receives events before the connection acceptance.
                       In any other case use the default of ``False``.
:param namespaces: a list of namespaces that are accepted, in addition to
                   any namespaces for which handlers have been defined. The
                   default is `['/']`, which always accepts connections to
                   the default namespace. Set to `'*'` to accept all
                   namespaces.
:param kwargs: Connection parameters for the underlying Engine.IO server.

The Engine.IO configuration supports the following settings:

:param async_mode: The asynchronous model to use. See the Deployment
                   section in the documentation for a description of the
                   available options. Valid async modes are
                   ``'threading'``, ``'eventlet'``, ``'gevent'`` and
                   ``'gevent_uwsgi'``. If this argument is not given,
                   ``'eventlet'`` is tried first, then ``'gevent_uwsgi'``,
                   then ``'gevent'``, and finally ``'threading'``.
                   The first async mode that has all its dependencies
                   installed is then one that is chosen.
:param ping_interval: The interval in seconds at which the server pings
                      the client. The default is 25 seconds. For advanced
                      control, a two element tuple can be given, where
                      the first number is the ping interval and the second
                      is a grace period added by the server.
:param ping_timeout: The time in seconds that the client waits for the
                     server to respond before disconnecting. The default
                     is 20 seconds.
:param max_http_buffer_size: The maximum size that is accepted for incoming
                             messages.  The default is 1,000,000 bytes. In
                             spite of its name, the value set in this
                             argument is enforced for HTTP long-polling and
                             WebSocket connections.
:param allow_upgrades: Whether to allow transport upgrades or not. The
                       default is ``True``.
:param http_compression: Whether to compress packages when using the
                         polling transport. The default is ``True``.
:param compression_threshold: Only compress messages when their byte size
                              is greater than this value. The default is
                              1024 bytes.
:param cookie: If set to a string, it is the name of the HTTP cookie the
               server sends back to the client containing the client
               session id. If set to a dictionary, the ``'name'`` key
               contains the cookie name and other keys define cookie
               attributes, where the value of each attribute can be a
               string, a callable with no arguments, or a boolean. If set
               to ``None`` (the default), a cookie is not sent to the
               client.
:param cors_allowed_origins: Origin or list of origins that are allowed to
                             connect to this server. Only the same origin
                             is allowed by default. Set this argument to
                             ``'*'`` to allow all origins, or to ``[]`` to
                             disable CORS handling.
:param cors_credentials: Whether credentials (cookies, authentication) are
                         allowed in requests to this server. The default is
                         ``True``.
:param monitor_clients: If set to ``True``, a background task will ensure
                        inactive clients are closed. Set to ``False`` to
                        disable the monitoring task (not recommended). The
                        default is ``True``.
:param transports: The list of allowed transports. Valid transports
                   are ``'polling'`` and ``'websocket'``. Defaults to
                   ``['polling', 'websocket']``.
:param engineio_logger: To enable Engine.IO logging set to ``True`` or pass
                        a logger object to use. To disable logging set to
                        ``False``. The default is ``False``. Note that
                        fatal errors are logged even when
                        ``engineio_logger`` is ``False``.
Nc	           
          U=(       d    SnU=(       d    UnU R                   R                  SUU=(       d    SU5        U R                  R                  XXdXWUS9  g)ai	  Emit a custom event to one or more connected clients.

: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 client or clients. 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 to: The recipient of the message. This can be set to the
           session ID of a client to address only that client, to any
           custom room created by the application to address all
           the clients in that room, or to a list of custom room
           names. If this argument is omitted the event is broadcasted
           to all connected clients.
:param room: Alias for the ``to`` parameter.
:param skip_sid: The session ID of a client to skip when broadcasting
                 to a room or to all clients. This can be used to
                 prevent a message from being sent to the sender. To
                 skip multiple sids, pass a list.
:param namespace: The Socket.IO namespace for the event. If this
                  argument is omitted the event is emitted to the
                  default namespace.
:param callback: If given, this function will be called to acknowledge
                 the client has received the message. The arguments
                 that will be passed to the function are those provided
                 by the client. Callback functions can only be used
                 when addressing an individual client.
:param ignore_queue: Only used when a message queue is configured. If
                     set to ``True``, the event is emitted to the
                     clients directly, without going through the queue.
                     This is more efficient, but only works when a
                     single server process is used. It is recommended
                     to always leave this parameter with its default
                     value of ``False``.

Note: this method is not thread safe. If multiple threads are emitting
at the same time to the same client, then messages composed of
multiple packets may end up being sent in an incorrect sequence. Use
standard concurrency solutions (such as a Lock object) to prevent this
situation.
/zemitting event "%s" to %s [%s]all)roomskip_sidcallbackignore_queueN)loggerinfomanageremit)	selfeventdatator   r   	namespacer   r   s	            L/home/admin/cozy_coffee/venv/lib/python3.13/site-packages/socketio/server.pyr   Server.emitw   sY    X $	zT95		3%y#+'3 	 	5    c                 *    U R                  SXX4XVUS9  g)a  Send a message to one or more connected clients.

This function emits an event with the name ``'message'``. Use
:func:`emit` to issue custom event names.

:param data: The data to send to the client or clients. 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 to: The recipient of the message. This can be set to the
           session ID of a client to address only that client, to any
           any custom room created by the application to address all
           the clients in that room, or to a list of custom room
           names. If this argument is omitted the event is broadcasted
           to all connected clients.
:param room: Alias for the ``to`` parameter.
:param skip_sid: The session ID of a client to skip when broadcasting
                 to a room or to all clients. This can be used to
                 prevent a message from being sent to the sender. To
                 skip multiple sids, pass a list.
:param namespace: The Socket.IO namespace for the event. If this
                  argument is omitted the event is emitted to the
                  default namespace.
:param callback: If given, this function will be called to acknowledge
                 the client has received the message. The arguments
                 that will be passed to the function are those provided
                 by the client. Callback functions can only be used
                 when addressing an individual client.
:param ignore_queue: Only used when a message queue is configured. If
                     set to ``True``, the event is emitted to the
                     clients directly, without going through the queue.
                     This is more efficient, but only works when a
                     single server process is used. It is recommended
                     to always leave this parameter with its default
                     value of ``False``.
message)r   r   r   r   r   r   r   N)r   )r   r   r   r   r   r   r   r   s           r   sendServer.send   s"    L 			)$D%+ 	 	-r   c           	        ^	^
 Uc  Uc  [        S5      eU R                  (       d  [        S5      eU R                  R	                  5       m
/ m	U	U
4S jnU R                  XU=(       d    UUXS9  T
R                  US9(       d  [        R                  " 5       e[        T	S   5      S:  a  T	S   $ [        T	S   5      S:X  a  T	S   S   $ S$ )	a  Emit a custom event to a client and wait for the response.

This method issues an emit with a callback and waits for the callback
to be invoked before returning. If the callback isn't invoked before
the timeout, then a ``TimeoutError`` exception is raised. If the
Socket.IO connection drops during the wait, this method still waits
until the specified timeout.

: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 client or clients. 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 to: The session ID of the recipient client.
:param sid: Alias for the ``to`` parameter.
:param namespace: The Socket.IO namespace for the event. If this
                  argument is omitted the event is emitted to the
                  default namespace.
:param timeout: The waiting timeout. If the timeout is reached before
                the client acknowledges the event, then a
                ``TimeoutError`` exception is raised.
:param ignore_queue: Only used when a message queue is configured. If
                     set to ``True``, the event is emitted to the
                     client directly, without going through the queue.
                     This is more efficient, but only works when a
                     single server process is used. It is recommended
                     to always leave this parameter with its default
                     value of ``False``.

Note: this method is not thread safe. If multiple threads are emitting
at the same time to the same client, then messages composed of
multiple packets may end up being sent in an incorrect sequence. Use
standard concurrency solutions (such as a Lock object) to prevent this
situation.
NzCannot use call() to broadcast.z/Cannot use call() when async_handlers is False.c                  H   > TR                  U 5        TR                  5         g N)appendset)argscallback_argscallback_events    r   event_callback#Server.call.<locals>.event_callback  s      & r   )r   r   r   r   r   )timeoutr   r   )

ValueErrorasync_handlersRuntimeErroreiocreate_eventr   waitr   TimeoutErrorlen)r   r   r   r   sidr   r+   r   r)   r'   r(   s            @@r   callServer.call   s    N :#+>??""AC C..0	! 			%si) 	 	F""7"3))++#&}Q'7#81#<}Q 	(+M!,<(=(Bq!!$		r   c                     U=(       d    SnU R                   R                  SXU5        U R                  R                  XU5        g)a  Enter a room.

This function adds the client to a room. The :func:`emit` and
:func:`send` functions can optionally broadcast events to all the
clients in a room.

:param sid: Session ID of the client.
:param room: Room name. If the room does not exist it is created.
:param namespace: The Socket.IO namespace for the event. If this
                  argument is omitted the default namespace is used.
r   z%s is entering room %s [%s]N)r   r   r   
enter_roomr   r4   r   r   s       r   r8   Server.enter_room  s9     $	69M5r   c                     U=(       d    SnU R                   R                  SXU5        U R                  R                  XU5        g)a  Leave a room.

This function removes the client from a room.

:param sid: Session ID of the client.
:param room: Room name.
:param namespace: The Socket.IO namespace for the event. If this
                  argument is omitted the default namespace is used.
r   z%s is leaving room %s [%s]N)r   r   r   
leave_roomr9   s       r   r<   Server.leave_room   s9     $	5s)L5r   c                     U=(       d    SnU R                   R                  SX5        U R                  R                  X5        g)zClose a room.

This function removes all the clients from the given room.

:param room: Room name.
:param namespace: The Socket.IO namespace for the event. If this
                  argument is omitted the default namespace is used.
r   zroom %s is closing [%s]N)r   r   r   
close_room)r   r   r   s      r   r?   Server.close_room.  s5     $	2DD0r   c                     U=(       d    SnU R                   R                  X5      nU R                  R                  U5      nUR	                  U0 5      $ )a  Return the user session for a client.

:param sid: The session id of the client.
:param namespace: The Socket.IO namespace. If this argument is omitted
                  the default namespace is used.

The return value is a dictionary. Modifications made to this
dictionary are not guaranteed to be preserved unless
``save_session()`` is called, or when the ``session`` context manager
is used.
r   )r   eio_sid_from_sidr/   get_session
setdefault)r   r4   r   eio_sideio_sessions        r   rC   Server.get_session;  sI     $	,,//?hh**73%%i44r   c                     U=(       d    SnU R                   R                  X5      nU R                  R                  U5      nX%U'   g)zStore the user session for a client.

:param sid: The session id of the client.
:param session: The session dictionary.
:param namespace: The Socket.IO namespace. If this argument is omitted
                  the default namespace is used.
r   N)r   rB   r/   rC   )r   r4   sessionr   rE   rF   s         r   save_sessionServer.save_sessionL  s>     $	,,//?hh**73!(Ir   c                 6   ^^  " UU4S jS5      nU" U TT5      $ )a  Return the user session for a client with context manager syntax.

:param sid: The session id of the client.

This is a context manager that returns the user session dictionary for
the client. Any changes that are made to this dictionary inside the
context manager block are saved back to the session. Example usage::

    @sio.on('connect')
    def on_connect(sid, environ):
        username = authenticate_user(environ)
        if not username:
            return False
        with sio.session(sid) as session:
            session['username'] = username

    @sio.on('message')
    def on_message(sid, msg):
        with sio.session(sid) as session:
            print('received message from ', session['username'])
c                   8   > \ rS rSrS rU U4S jrU U4S jrSrg)0Server.session.<locals>._session_context_managerio  c                 6    Xl         X l        X0l        S U l        g r#   )serverr4   r   rI   )r   rP   r4   r   s       r   __init__9Server.session.<locals>._session_context_manager.__init__p  s    $!*#r   c                 Z   > U R                   R                  TTS9U l        U R                  $ Nr   )rP   rC   rI   )r   r   r4   s    r   	__enter__:Server.session.<locals>._session_context_manager.__enter__v  s.    #{{66sAJ  7  L||#r   c                 P   > U R                   R                  TU R                  TS9  g rT   )rP   rJ   rI   )r   r&   r   r4   s     r   __exit__9Server.session.<locals>._session_context_manager.__exit__{  s%    ((dll3< ) >r   )r   rP   rI   r4   N)__name__
__module____qualname____firstlineno__rQ   rV   rY   __static_attributes__)r   r4   s   r   _session_context_managerrN   o  s    $$
> >r   r`    )r   r4   r   r`   s    `` r   rI   Server.sessionY  s    ,	> 	>  (c9==r   c                    U=(       d    SnU(       a  U R                   R                  X5      nOU R                   R                  X5      nU(       a  U R                  R	                  SX5        U R                   R                  XS9nU R                  XPR                  [        R                  US95        U R                  SX!U R                  R                  5        U R                   R                  XSS9  gg)a  Disconnect a client.

:param sid: Session ID of the client.
:param namespace: The Socket.IO namespace to disconnect. If this
                  argument is omitted the default namespace is used.
:param ignore_queue: Only used when a message queue is configured. If
                     set to ``True``, the disconnect is processed
                     locally, without broadcasting on the queue. It is
                     recommended to always leave this parameter with
                     its default value of ``False``.
r   zDisconnecting %s [%s]rU   
disconnectT)r   r   N)r   is_connectedcan_disconnectr   r   pre_disconnect_send_packetpacket_classr   
DISCONNECT_trigger_eventreasonSERVER_DISCONNECTrd   )r   r4   r   r   	delete_itrE   s         r   rd   Server.disconnect  s     $	11#AI33CCIKK4cEll11#1KGg'8'8!!Y (9 (8 9i $ = =?LL##C15 $ 7 r   c                 n    U R                   R                  S5        U R                  R                  5         g)zStop Socket.IO background tasks.

This method stops all background activity initiated by the Socket.IO
server. It must be called before shutting down the web server.
zSocket.IO is shutting downN)r   r   r/   shutdownr   s    r   rq   Server.shutdown  s'     	56r   c                 8    U R                   R                  X5      $ )a  Handle an HTTP request from the client.

This is the entry point of the Socket.IO application, using the same
interface as a WSGI application. For the typical usage, this function
is invoked by the :class:`Middleware` instance, but it can be invoked
directly when the middleware is not used.

:param environ: The WSGI environment.
:param start_response: The WSGI ``start_response`` function.

This function returns the HTTP response body to deliver to the client
as a byte sequence.
)r/   handle_request)r   environstart_responses      r   ru   Server.handle_request  s     xx&&w??r   c                 B    U R                   R                  " U/UQ70 UD6$ )a  Start a background task using the appropriate async model.

This is a utility function that applications can use to start a
background task using the method that is compatible with the
selected async mode.

:param target: the target function to execute.
:param args: arguments to pass to the function.
:param kwargs: keyword arguments to pass to the function.

This function returns an object that represents the background task,
on which the ``join()`` methond can be invoked to wait for the task to
complete.
)r/   start_background_task)r   targetr&   kwargss       r   rz   Server.start_background_task  s#     xx--fFtFvFFr   c                 8    U R                   R                  U5      $ )zSleep for the requested amount of time using the appropriate async
model.

This is a utility function that applications can use to put a task to
sleep without having to worry about using the correct call for the
selected async mode.
)r/   sleep)r   secondss     r   r   Server.sleep  s     xx~~g&&r   c           
           SSK Jn  U" XX#XEUS9$ )a  Instrument the Socket.IO server for monitoring with the `Socket.IO
Admin UI <https://socket.io/docs/v4/admin-ui/>`_.

:param auth: Authentication credentials for Admin UI access. Set to a
             dictionary with the expected login (usually ``username``
             and ``password``) or a list of dictionaries if more than
             one set of credentials need to be available. For more
             complex authentication methods, set to a callable that
             receives the authentication dictionary as an argument and
             returns ``True`` if the user is allowed or ``False``
             otherwise. To disable authentication, set this argument to
             ``False`` (not recommended, never do this on a production
             server).
:param mode: The reporting mode. The default is ``'development'``,
             which is best used while debugging, as it may have a
             significant performance effect. Set to ``'production'`` to
             reduce the amount of information that is reported to the
             admin UI.
:param read_only: If set to ``True``, the admin interface will be
                  read-only, with no option to modify room assignments
                  or disconnect clients. The default is ``False``.
:param server_id: The server name to use for this server. If this
                  argument is omitted, the server generates its own
                  name.
:param namespace: The Socket.IO namespace to use for the admin
                  interface. The default is ``/admin``.
:param server_stats_interval: The interval in seconds at which the
                              server emits a summary of it stats to all
                              connected admins.
r   )InstrumentedServer)authmode	read_only	server_idr   server_stats_interval)adminr   )r   r   r   r   r   r   r   r   s           r   
instrumentServer.instrument  s     B 	.!$"79 	9r   c                     UR                  5       n[        U[        5      (       a%  U H  nU R                  R	                  X5        M      gU R                  R	                  X5        g)z$Send a Socket.IO packet to a client.N)encode
isinstancelistr/   r   )r   rE   pktencoded_packeteps        r   rh   Server._send_packet  sF    nd++$g* % HHMM'2r   c                 :    U R                   R                  X5        g)z(Send a raw Engine.IO packet to a client.N)r/   send_packet)r   rE   eio_pkts      r   _send_eio_packetServer._send_eio_packet   s    W.r   c           	      D   U=(       d    SnSnX R                   ;   d.  X R                  ;   d  U R                  S:X  d  X R                  ;   a  U R                  R	                  X5      nUc/  U R                  XR                  [        R                  SUS95        gU R                  (       a0  U R                  XR                  [        R                  SU0US95        [        R                  " 5       R                  n U(       a"  U R                  SX$U R                  U   U5      nO! U R                  SX$U R                  U   5      nUS	L a  U R                  (       aI  U R                  R#                  XB5        U R                  XR                  [        R$                  XRS95        O.U R                  XR                  [        R                  UUS95        U R                  R'                  XBSS9  gU R                  (       d1  U R                  XR                  [        R                  SU0US95        gg! [          a%    U R                  SX$U R                  U   S5      n GNf = f! [        R                   a  nUR                  nS	n SnAGNESnAf[         a
    S
S0nS	n GN[f = f)z#Handle a client connection request.r   N*zUnable to connect)r   r   r4   rU   connectFr   zConnection refused by serverTr   )handlersnamespace_handlers
namespacesr   r   rh   ri   r   CONNECT_ERRORalways_connectCONNECTr   ConnectionRefusedError
error_argsrk   rv   	TypeErrorrg   rj   rd   )r   rE   r   r   r4   fail_reasonsuccessexcs           r   _handle_connectServer._handle_connect  su   $	%6M6M)M??c)Y//-I,,&&w:C;g'8'8$$+># (9 (% & g'8'8	 (9 (C D 779DD	--yt||G/DdLP"11!94<<3HJG e""++C;!!'+<+<%%K ,= ,N O !!'+<+<(({' ,= ,) * LL##C#F$$g'8'8	 (9 (C D %) ! P"11!94<<3H$PGP 00 	..KG% 	$&DEKG	s<   9(I  # H. .+II  II   J4JJJc                 X   U=(       d    SnU R                   R                  X5      nU R                   R                  XB5      (       d  gU R                   R                  XBS9  U R	                  SX$U=(       d    U R
                  R                  5        U R                   R                  XBSS9  g)zHandle a client disconnect.r   NrU   rd   Tr   )r   sid_from_eio_sidre   rg   rk   rl   CLIENT_DISCONNECTrd   )r   rE   r   rl   r4   s        r   _handle_disconnectServer._handle_disconnect5  s    $	ll++G?||((88##C#=L)"Cdkk&C&C	ETBr   c           	         U=(       d    SnU R                   R                  X5      nU R                  R                  SUS   UU5        U R                   R	                  XR5      (       d  U R                  R                  SXR5        gU R                  (       a  U R                  U R                  XXX#5        gU R                  XXUU5        g)z Handle an incoming client event.r   z received event "%s" from %s [%s]r   z#%s is not connected to namespace %sN)	r   r   r   r   re   warningr-   rz   _handle_event_internalr   rE   r   idr   r4   s         r   _handle_eventServer._handle_event@  s    $	ll++G?;T!Wc"	$||((88KK E #0&&t'B'BD'.iE ''7)(*,r   c           
         UR                   " US   XR/USS  Q76 nXpR                  :w  a]  UbY  Uc  / nO$[        U[        5      (       a  [	        U5      nOU/nUR                  X0R                  [        R                  XVUS95        g g g )Nr   r   )r   r   r   )	rk   not_handledr   tupler   rh   ri   r   ACK)r   rP   r4   rE   r   r   r   rs           r   r   Server._handle_event_internalQ  s    !!$q'9EDHE   R^ yAu%%Aws):):

iT *; *C D &4 r   c                     U=(       d    SnU R                   R                  X5      nU R                  R                  SXR5        U R                   R	                  XSU5        g)z#Handle ACK packets from the client.r   zreceived ack from %s [%s]N)r   r   r   r   trigger_callbackr   s         r   _handle_ackServer._handle_ack`  sI    $	ll++G?4cE%%ct4r   c                     U R                  XU5      u  pCU(       a   U" U6 $ U R                  X#5      u  pCU(       a  UR                  " U/UQ76 $ U R                  $ ! [         a    US:X  a
  U" USS 6 s $ e f = f)z$Invoke an application event handler.rd   N)_get_event_handlerr   _get_namespace_handlertrigger_eventr   )r   r   r   r&   handlers        r   rk   Server._trigger_eventg  s     //$G~% 33ID((666###  L("D"I..s   A A75A7c                     U R                   (       d!  SU l         U R                  R                  5         X R                  U'   g)z&Handle the Engine.IO connection event.TN)manager_initializedr   
initializerv   )r   rE   rv   s      r   _handle_eio_connectServer._handle_eio_connect{  s/    '''+D$LL##% 'Wr   c                    XR                   ;   a  U R                   U   nUR                  U5      (       a  U R                   U	 UR                  [        R                  :X  a2  U R                  XR                  UR                  UR                  5        gU R                  XR                  UR                  UR                  5        ggU R                  US9nUR                  [        R                  :X  a'  U R                  XR                  UR                  5        gUR                  [        R                  :X  a1  U R                  XR                  U R                  R                   5        gUR                  [        R"                  :X  a2  U R                  XR                  UR                  UR                  5        gUR                  [        R$                  :X  a2  U R                  XR                  UR                  UR                  5        gUR                  [        R                  :X  d  UR                  [        R&                  :X  a  X0R                   U'   gUR                  [        R(                  :X  a  [+        S5      e[+        S5      e)zDispatch Engine.IO messages.)r   z Unexpected CONNECT_ERROR packet.zUnknown packet type.N)_binary_packetadd_attachmentpacket_typer   BINARY_EVENTr   r   r   r   r   ri   r   r   rj   r   rl   r   EVENTr   
BINARY_ACKr   r,   )r   rE   r   r   s       r   _handle_eio_messageServer._handle_eio_message  s   )))%%g.C!!$''''0??f&9&99&&wsvv'*xx1 $$WmmSVVSXXN ( ##4#8C&..0$$WmmSXXFF$5$55''(,(E(EGFLL0""7MM366388LFJJ.  --JF$7$77OOv'8'88/2##G,F$8$88 !CDD !788r   c                     [        U R                  R                  5       5      R                  5        H  nU R	                  XU5        M     XR
                  ;   a  U R
                  U	 gg)z"Handle Engine.IO disconnect event.N)r   r   get_namespacescopyr   rv   )r   rE   rl   ns       r   _handle_eio_disconnectServer._handle_eio_disconnect  sR    dll113499;A##G7 <ll"W% #r   c                 "    [         R                  $ r#   )engineior   rr   s    r   _engineio_server_classServer._engineio_server_class  s    r   )r   )NNNNNNF)NNNNNF)NNNN<   Fr#   )NF)r   )NdevelopmentFNz/admin   )!r[   r\   r]   r^   __doc__r   r   r5   r8   r<   r?   rC   rJ   rI   rd   rq   ru   rz   r   r   rh   r   r   r   r   r   r   rk   r   r   r   r   r_   ra   r   r   r   r      s    iT CG9>25h GK).(-T CG&+9v6 615")&>P76@ G"' CH-5)*%9N3//Db	C,"D5$((9<&r   r   )
loggingr    r   r   r   	getLoggerdefault_logger
BaseServerr   ra   r   r   <module>r      s9        ""#45\
[## \
r   