
    i                         d dl Z d dl mZ d dlmZ 	 d dlZdZn# e$ r	 d dlmZ Y nw xY w G d de j                  Z	e G d de          Z
n G d	 d          Z
e	ej        ej        ee
e j        d
ZdS )    N)queue)Event)SimpleWebSocketWSGIc                   .     e Zd ZdZg i f fd	Zd Z xZS )Threadz
    This wrapper class provides gevent Greenlet interface that is compatible
    with the standard library's Thread class.
    c                 B     t                      j        |g|R i | d S N)super__init__)selftargetargskwargs	__class__s       H/usr/local/lib/python3.11/dist-packages/engineio/async_drivers/gevent.pyr   zThread.__init__   s0    1$111&11111    c                 *    |                                  S r	   )runr   s    r   _runzThread._run   s    xxzzr   )__name__
__module____qualname____doc__r   r   __classcell__r   s   @r   r   r      s]          %'r 2 2 2 2 2 2      r   r   c                   "     e Zd ZdZ fdZ xZS )WebSocketWSGIz
        This wrapper class provides a gevent WebSocket interface that is
        compatible with eventlet's implementation, using the simple-websocket
        package.
        c                     dd l }dd l}t                                          ||t          |j        j        |j        j                   d S )Nr   )thread_classevent_classselector_class)	gevent.eventgevent.selectorsr
   r   r   eventr   	selectorsDefaultSelector)r   handlerservergeventr   s       r   r   zWebSocketWSGI.__init__    se      ####GGWf*0)/);,2,<,L  N N N N Nr   )r   r   r   r   r   r   r   s   @r   r   r      sK        	 	
		N 		N 		N 		N 		N 		N 		N 		N 		Nr   r   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )r   z
        This wrapper class provides a gevent WebSocket interface that is
        compatible with eventlet's implementation, using the gevent-websocket
        package.
        c                     || _         d S r	   )app)r   r(   r)   s      r   r   zWebSocketWSGI.__init__1   s    DHHHr   c                    d|vrt          d          |d         | _        || _        | j        j        | _        | j        j        | _        | j        j        | _        | j        j        | _        |                     |           S )Nzwsgi.websocketzThe gevent-websocket server is not configured appropriately. See the Deployment section of the documentation for more information.)RuntimeError_sockenvironversionpathoriginprotocolr-   )r   r1   start_responses      r   __call__zWebSocketWSGI.__call__4   s}    w.." $I J J J !!12DJ"DL:-DL
DI*+DK J/DM88D>>!r   c                 4    | j                                         S r	   )r0   closer   s    r   r9   zWebSocketWSGI.closeB   s    :##%%%r   c                 6    | j                             |          S r	   )r0   send)r   messages     r   r;   zWebSocketWSGI.sendE   s    :??7+++r   c                 4    | j                                         S r	   )r0   receiver   s    r   waitzWebSocketWSGI.waitH   s    :%%'''r   N)	r   r   r   r   r   r7   r9   r;   r?    r   r   r   r   +   si        	 	
	 	 		" 	" 	"	& 	& 	&	, 	, 	,	( 	( 	( 	( 	(r   )threadr   queue_emptyr%   	websocketsleep)r*   r   r#   r   geventwebsocketr   ImportError&engineio.async_drivers._websocket_wsgiGreenletr   r   JoinableQueueEmptyrD   _asyncr@   r   r   <module>rL      sE               K K K KJJJJJJJJK
	 	 	 	 	V_ 	 	 	 "N N N N N+ N N N N"( ( ( ( ( ( ( (D  ;\
 
s    ''