
    tf[,                        d dl Z d dlZd dlZ ej                     d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dlmZ d dlmZ d dlmZ d dlmZmZmZ d d	lmZmZ d
Ze G d dej                              Z ej        e            ej        e            G d dej                  Ze G d de                      Z  G d dej!                  Z"dS )    N)public)protocol)ComponentConfig)	parse_url)WampWebSocketClientFactory)WampRawSocketClientFactory)PerMessageDeflateOfferPerMessageDeflateResponsePerMessageDeflateResponseAccept)ITransportHandlerISession)ApplicationSessionApplicationSessionFactoryApplicationRunnerc                   0    e Zd ZdZ ej                    ZdS )r   z
    WAMP application session for asyncio-based applications.

    Implements:

        * ``autobahn.wamp.interfaces.ITransportHandler``
        * ``autobahn.wamp.interfaces.ISession``
    N)__name__
__module____qualname____doc__txaiomake_loggerlog     T/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/autobahn/asyncio/wamp.pyr   r   7   s*          %


CCCr   r   c                   B    e Zd ZU dZeZeed<   	  ej                    Z	dS )r   zJ
    WAMP application session factory for asyncio-based applications.
    sessionN)
r   r   r   r   r   r   __annotations__r   r   r   r   r   r   r   r   K   sD           #5G444
 %


CCCr   r   c                   r    e Zd ZdZ ej                    Z	 	 	 	 	 	 ddZed             Z	ed	d            Z
dS )
r   z
    This class is a convenience tool mainly for development and quick hosting
    of WAMP application components.

    It can host a WAMP application component in a WAMP-over-WebSocket client
    connecting to a WAMP router.
    Nc                    t          |          t          k    sJ |t          |          t          k    sJ |t          |          t          k    sJ |t          |          t          k    sJ |t          |          t          k    sJ || _        || _        |pt                      | _        || _        || _        || _        || _	        dS )aU  

        :param url: The WebSocket URL of the WAMP router to connect to (e.g. `ws://somehost.com:8090/somepath`)
        :type url: str

        :param realm: The WAMP realm to join the application session to.
        :type realm: str

        :param extra: Optional extra configuration to forward to the application component.
        :type extra: dict

        :param serializers: A list of WAMP serializers to use (or None for default serializers).
           Serializers must implement :class:`autobahn.wamp.interfaces.ISerializer`.
        :type serializers: list

        :param ssl: An (optional) SSL context instance or a bool. See
           the documentation for the `loop.create_connection` asyncio
           method, to which this value is passed as the ``ssl``
           keyword parameter.
        :type ssl: :class:`ssl.SSLContext` or bool

        :param proxy: Explicit proxy server to use; a dict with ``host`` and ``port`` keys
        :type proxy: dict or None

        :param headers: Additional headers to send (only applies to WAMP-over-WebSocket).
        :type headers: dict
        N)
typestrdicturlrealmextraserializerssslproxyheaders)selfr$   r%   r&   r'   r(   r)   r*   s           r   __init__zApplicationRunner.__init__e   s    F CyyC}Us 2 2 2 2}Ut 3 3 3 3$w--4"7"7"7"7}Ut 3 3 3 3
_dff
&
r   c                     t                      )zF
        Stop reconnecting, if auto-reconnecting was enabled.
        )NotImplementedErrorr+   s    r   stopzApplicationRunner.stop   s    
 "###r   Tinfoc                 X    t                    r fd}n} j                            d          r@t           j                  \  }}} j        r j        d         nd}t          ||          }	nvt           j                  \  }}}}
}}t          | j         j         j         j	                  }	t                      g}d }|	                    ddd	d
dddddd||            j        |}n, j        r|st          d j        j        z             j        }t!          j                    }|                                rQ|rOt!          j        t!          j                               t!          j                    }t+          |	d          r||	_        t.          j        dk    sJ |t.          j        _        |                    |	|||          }|s|S |                    |          \  }}t/          j        |           	 |                    t<          j        |j                    n# tB          $ r Y nw xY w	 |"                                 n# tF          $ r Y nw xY w|j$        r,|                    |j$        %                                           |&                                 dS )a  
        Run the application component. Under the hood, this runs the event
        loop (unless `start_loop=False` is passed) so won't return
        until the program is done.

        :param make: A factory that produces instances of :class:`autobahn.asyncio.wamp.ApplicationSession`
           when called with an instance of :class:`autobahn.wamp.types.ComponentConfig`.
        :type make: callable

        :param start_loop: When ``True`` (the default) this method
            start a new asyncio loop.
        :type start_loop: bool

        :returns: None is returned, unless you specify
            `start_loop=False` in which case the coroutine from calling
            `loop.create_connection()` is returned. This will yield the
            (transport, protocol) pair.
        c                  J   t          j        j                  } 	  |           }|S # t          $ rn}j                            d                    |                     t          j                    }|	                                r|
                                  d }~ww xY w)Nz0ApplicationSession could not be instantiated: {})r   r%   r&   	Exceptionr   errorformatasyncioget_event_loop
is_runningr0   )cfgr   eloopmaker+   s       r   createz%ApplicationRunner.run.<locals>.create   s    %dj$*==	#"d3iiG #N !   HNN#U#\#\]^#_#_```"133D(( $		s   * 
B"A)BB"rsr   N)
serializer)r$   r'   r)   r*   c                 N    t          | t                    rt          |           S d S N)
isinstancer
   r   )responses    r   acceptz%ApplicationRunner.run.<locals>.accept   s0    h(ABB E:8DDDE Er   i   i   Fg      @g      ?Tg      $@g      @   )maxFramePayloadSizemaxMessagePayloadSizeautoFragmentSize
failByDropopenHandshakeTimeoutcloseHandshakeTimeout
tcpNoDelayautoPingIntervalautoPingTimeoutautoPingSizeperMessageCompressionOffersperMessageCompressionAcceptzpssl argument value passed to %s conflicts with the "ws:" prefix of the url argument. Did you mean to use "wss:"?r<   r7   )r(   )level)'callabler$   
startswithparse_rs_urlr'   r   parse_ws_urlr   r)   r*   r	   setProtocolOptionsr(   RuntimeError	__class__r   r7   r8   	is_closedset_event_loopnew_event_loophasattrr<   r   _explicit_frameworkconfigcreate_connectionrun_until_completestart_loggingadd_signal_handlersignalSIGTERMr0   r.   run_foreverKeyboardInterrupt_sessionleaveclose)r+   r=   
start_loop	log_levelr>   isSecurehostportr@   transport_factoryresourcepathparamsoffersrE   r(   r<   coro	transportr   s   ``                  r   runzApplicationRunner.run   sX   ( D>> 	# # # # # # # F8t$$ )	U#/#9#9 HdD 150@J)!,,dJ !;6j Y Y Y <H;Q;Q8HdD(D& !;6tx]a]muyu  JN  JV  !W  !W  !W -../FE E E
 00WGNBG<AFIGI<@BEAC>@MSMS 1 U U U 8CCx - -"NN+,- - - (C %''>> 	.
 	."7#9#;#;<<<)++D(&11 .)-!& (I5555 %%&7t%MM  	K$($;$;D$A$A!Y i0000''	BBBB&   
  """"$       C''(9(?(?(A(ABBBJJLLLLLs$   %H- -
H:9H:>I 
I I )NNNNNN)Tr1   )r   r   r   r   r   r   r   r,   r   r0   rx   r   r   r   r   r   Y   s          %


C !. . . .` $ $ V$ C C C VC C Cr   r   c                   ,    e Zd Zd Zd Zd Zd Zd ZdS )Sessionc                     d S rB   r   )r+   welcome_msgs     r   
on_welcomezSession.on_welcome(      r   c                     d S rB   r   r+   detailss     r   on_joinzSession.on_join+  r~   r   c                 .    |                                   d S rB   )
disconnectr   s     r   on_leavezSession.on_leave.  s    r   c                 D    |                      | j        j                   d S rB   )joinr`   r%   r/   s    r   
on_connectzSession.on_connect1  s    		$+#$$$$$r   c                     d S rB   r   r/   s    r   on_disconnectzSession.on_disconnect4  r~   r   N)r   r   r   r}   r   r   r   r   r   r   r   rz   rz   $  s_              % % %    r   rz   )#r7   re   r   use_asyncioautobahn.utilr   autobahn.wampr   autobahn.wamp.typesr   autobahn.websocket.utilr   rW   autobahn.rawsocket.utilrV   autobahn.asyncio.websocketr   autobahn.asyncio.rawsocketr   autobahn.websocket.compressr	   r
   r   autobahn.wamp.interfacesr   r   __all__r   registerabc_registerr   objectr   _SessionShimrz   r   r   r   <module>r      s  6                     " " " " " " / / / / / / = = = = = = = = = = = = A A A A A A A A A A A A? ? ? ? ? ? ? ? ? ? A @ @ @ @ @ @ @ 
 
 
 
 
4 
 
 
   - . . .  ( ) ) )     B    F F F F F F F FT    h#     r   