
    Lf[,                        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j6                               Z ej8                  e        ej:                  e        G d dej<                        Ze G d de             Z  G d dejB                        Z"y)    N)public)protocol)ComponentConfig)	parse_url)WampWebSocketClientFactory)WampRawSocketClientFactory)PerMessageDeflateOfferPerMessageDeflateResponsePerMessageDeflateResponseAccept)ITransportHandlerISession)ApplicationSessionApplicationSessionFactoryApplicationRunnerc                   2    e Zd ZdZ ej
                         Zy)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     P/var/www/cs2snipe.com/venv/lib/python3.12/site-packages/autobahn/asyncio/wamp.pyr   r   7   s     %


Cr   r   c                   D    e Zd ZU dZeZeed<   	  ej                         Z	y)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   s+     #5G4
 %


Cr   r   c                   h    e Zd ZdZ ej
                         Z	 	 	 	 	 	 ddZed        Z	edd       Z
y)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                 V   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 || _        || _        |xs
 t               | _        || _        || _        || _        || _	        y)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 CyC }Us 232}Ut 343$w-4"787}Ut 343
_df
&
r   c                     t               )zF
        Stop reconnecting, if auto-reconnecting was enabled.
        )NotImplementedErrorr+   s    r   stopzApplicationRunner.stop   s    
 "##r   c                     t              r fd}n} j                  j                  d      rDt         j                        \  }}} j                  r j                  d   nd}t        ||      }	nt         j                        \  }}}}
}}t        | j                   j                   j                   j                        }	t               g}d }|	j                  ddd	d
dddddd||        j                  |}n< j                  r$|s"t        d j                  j                  z         j                  }t!        j"                         }|j%                         rP|rNt!        j&                  t!        j(                                t!        j"                         }t+        |	d      r||	_        t.        j0                  dk(  sJ |t.        j2                  _        |j5                  |	|||      }|s|S |j7                  |      \  }}t/        j8                  |       	 |j;                  t<        j>                  |j@                         	 |jE                          |jH                  r)|j7                  |jH                  jK                                |jM                          y# tB        $ r Y bw xY w# tF        $ r Y `w xY w)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                  :   t        j                  j                        } 	  |       }|S # t        $ rd}j                  j                  dj                  |             t        j                         }|j                         r|j                           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    %djj$**=	#"3iG #N ! HHNN#U#\#\]^#_`"113D(		s   - 	BABBrsr   N)
serializer)r$   r'   r)   r*   c                 :    t        | t              rt        |       S y N)
isinstancer
   r   )responses    r   acceptz%ApplicationRunner.run.<locals>.accept   s    h(AB:8DD C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;   r6   )r(   )level)'callabler$   
startswithparse_rs_urlr'   r   parse_ws_urlr   r)   r*   r	   setProtocolOptionsr(   RuntimeError	__class__r   r6   r7   	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offersrD   r(   r;   coro	transportr   s   ``                  r   runzApplicationRunner.run   s   ( D># F88t$#/#9 HdD 150@0@))!,dJ !;6j Y <H;Q8HdD(D& !;6txx]a]m]muyuu  JN  JV  JV  !W -./FE
 00WGNBG<AFIGI<@BEAC>@MSMS 1 U 88Cxx"NNN++,- - ((C %%'>>
""7#9#9#;<))+D(&1)-!& ((I555 %%&7t%M K$($;$;D$A!Y i0''		B  "   ''(9(9(?(?(ABJJL# '  %  s$   "*J# J2 #	J/.J/2	J>=J>)NNNNNN)Tinfo)r   r   r   r   r   r   r   r,   r   r0   rw   r   r   r   r   r   Y   s]     %


C !.` $ $ C Cr   r   c                   *    e Zd Zd Zd Zd Zd Zd Zy)Sessionc                      y rA   r   )r+   welcome_msgs     r   
on_welcomezSession.on_welcome(      r   c                      y rA   r   r+   detailss     r   on_joinzSession.on_join+  r~   r   c                 $    | j                          y rA   )
disconnectr   s     r   on_leavezSession.on_leave.  s    r   c                 N    | j                  | j                  j                         y rA   )joinr_   r%   r/   s    r   
on_connectzSession.on_connect1  s    		$++##$r   c                      y rA   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   )#r6   rd   r   use_asyncioautobahn.utilr   autobahn.wampr   autobahn.wamp.typesr   autobahn.websocket.utilr   rV   autobahn.rawsocket.utilrU   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 
44 
 
    - .   ( ) B B  F F FTh## r   