ó
    ð›‘h‡  ã                   ó  • S SK r S SKrS SKrS SKJrJrJrJrJr  S SK	r	S SK
Jr  \	R                  " 5         S SKJrJrJr  S SKJr  S SKJrJr   S SKJr  S SKJr  S S	KJr  S S	KJr  S S
K J!r!  S SK"J#r#  S SK$J%r%J&r&J'r'  S SK(J)r)J*r*  S SK+J,r,J-r-J.r.J/r/  S SK0J1r1  / SQr2\ " S S\)Rf                  5      5       r3\,Rh                  " \35        \-Rj                  " \35         " S S\)Rl                  5      r6\ " S S\75      5       r8 " S S\35      r9 " S S\75      r: " S S\Rv                  5      r< " S S\)Rz                  5      r> " S S \75      r?\.Rh                  " \?5         " S! S"\75      r@\.Rh                  " \@5        g! \ a    \r GN/f = f)#é    N)ÚOptionalÚDictÚAnyÚListÚUnion)ÚWebSocketProtocol)ÚinlineCallbacksÚsucceedÚDeferred)Úservice)ÚIReactorCoreÚIStreamClientEndpoint)ÚCertificateOptions)Úpublic)Ú	parse_url)ÚWampWebSocketClientFactory)ÚWampRawSocketClientFactory)ÚPerMessageDeflateOfferÚPerMessageDeflateResponseÚPerMessageDeflateResponseAccept)ÚprotocolÚauth)ÚITransportHandlerÚISessionÚIAuthenticatorÚISerializer)ÚComponentConfig)ÚApplicationSessionÚApplicationSessionFactoryÚApplicationRunnerÚApplicationÚServiceÚSessionc                   ó:   • \ rS rSrSr\R                  " 5       rSrg)r   éK   z³
WAMP application session for Twisted-based applications.

Implements:

    * :class:`autobahn.wamp.interfaces.ITransportHandler`
    * :class:`autobahn.wamp.interfaces.ISession`
© N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚtxaioÚmake_loggerÚlogÚ__static_attributes__r&   ó    ÚYC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\autobahn/twisted/wamp.pyr   r   K   s   † ñð ×
Ò
Ó
ƒCr0   r   c                   óL   • \ rS rSr% Sr\r\\S'    \R                  " 5       r
Srg)r   é_   zB
WAMP application session factory for Twisted-based applications.
Úsessionr&   N)r'   r(   r)   r*   r+   r   r4   Ú__annotations__r,   r-   r.   r/   r&   r0   r1   r   r   _   s)   ‡ ñð #5€GÐÓ4ðð ×
Ò
Ó
ƒCr0   r   c                   ór  • \ rS rSrSr\R                  " 5       r            SS\S\	\   S\	\
\\4      S\	\\      S\	\   S	\	\
\\4      S
\	\
\\4      S\	\
\\4      S\	\   S\	\   S\	\   S\	\   S\	\   4S jjr\S 5       r\   SS\S\S\S\	\   S\	\   S\\" S5      \4   4S jj5       rSrg)r    él   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.
NÚurlÚrealmÚextraÚserializersÚsslÚproxyÚheadersÚwebsocket_optionsÚmax_retriesÚinitial_retry_delayÚmax_retry_delayÚretry_delay_growthÚretry_delay_jitterc                 ó  • Ub  [        U5      [        :X  d   eXl        X l        U=(       d
    [        5       U l        X@l        XPl        X`l        Xpl        X€l	        X�l
        X l        X°l        XÀl        XÐl        SU l        SU l        g)až  

:param url: The WebSocket URL of the WAMP router to connect to (e.g. `ws://example.com:8080/mypath`)
:param realm: The WAMP realm to join the application session to.
:param extra: Optional extra configuration to forward to the application component.
: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: (Optional). If specified this should be an
    instance suitable to pass as ``sslContextFactory`` to
    :class:`twisted.internet.endpoints.SSL4ClientEndpoint`` such
    as :class:`twisted.internet.ssl.CertificateOptions`. Leaving
    it as ``None`` will use the result of calling Twisted
    :meth:`twisted.internet.ssl.platformTrust` which tries to use
    your distribution's CA certificates.
:param proxy: Explicit proxy server to use; a dict with ``host`` and ``port`` keys.
:param headers: Additional headers to send (only applies to WAMP-over-WebSocket).
:param websocket_options: Specific WebSocket options to set (only applies to WAMP-over-WebSocket).
    If not provided, conservative and practical default are chosen.
:param max_retries: Maximum number of reconnection attempts. Unlimited if set to -1.
:param initial_retry_delay: Initial delay for reconnection attempt in seconds (Default: 1.0s).
:param max_retry_delay: Maximum delay for reconnection attempts in seconds (Default: 60s).
:param retry_delay_growth: The growth factor applied to the retry delay between reconnection
    attempts (Default 1.5).
:param retry_delay_jitter: A 0-argument callable that introduces noise into the
    delay (Default ``random.random``).
Nr   )ÚtypeÚdictr8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   Ú_client_serviceÚ_connect_successes)Úselfr8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   s                 r1   Ú__init__ÚApplicationRunner.__init__x   s}   € ðV ‘¤ e£´Ó!4Ð5Ð4àŒØŒ
Ø—_œd›fˆŒ
Ø&ÔØŒØŒ
ØŒØ!2ÔØ&ÔØ#6Ô Ø.ÔØ"4ÔØ"4Ôð  $ˆÔà"#ˆÕr0   c                 óÊ   • U R                   R                  SU R                  R                  S9  U R                  (       a  U R                  R                  5       $ [        S5      $ )z6
Stop reconnecting, if auto-reconnecting was enabled.
z{klass}.stop()©ÚklassN)r.   ÚdebugÚ	__class__r'   rH   ÚstopServicer
   ©rJ   s    r1   ÚstopÚApplicationRunner.stop¸   sK   € ð
 	�‰�‰Ð'¨t¯~©~×/FÑ/FˆÑGà××Ø×'Ñ'×3Ñ3Ó5Ð5ä˜4“=Ð r0   Ústart_reactorÚauto_reconnectÚ	log_levelÚendpointÚreactorÚreturnc                 ó–	  ^ ^^^^#^$^%• T R                   R                  ST R                  R                  S9  T(       aD  SSKJm  [        R                  " 5         T[        R                  l	        [        R                  " US9  [        T5      (       a
  UUU U4S jnOTnT R                  R                  S5      (       aD  [        T R                  5      u  p‰n
T R                  (       a  T R                  S   OSn[!        X{S	9nOã[#        T R                  5      u  p‰p­pï[%        UT R                  T R                  T R&                  T R(                  S
9n[+        5       /nS n0 S[,        R.                  _SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_S U_S!U_S"S#_S$S%SS&.EnT R0                  (       a  UR3                  T R0                  5        UR4                  " S>0 UD6  SUl        U(       a  UnOËSnT R8                  b6  U(       d"  [;        S'T R                  R                  -  5      eT R8                  nOU(       a  SS(KJn  U" U	5      nSSKJm  T R&                  b2  SS)K J!n  U" TT R&                  S*   T R&                  S+   5      nUUl"        O,U(       a  SS,K J#n  Uc   eU" TXšU5      nOSS)K J!n  U" TXš5      nS- m$U$UU 4S. jnSnU(       a   SS/K$J%n  SS0K$J&m#  SnU(       Ga
  T R                   R                  S15        T RP                  c4  T RR                  c'  T RT                  c  T RV                  c  T RX                  be  T RT                  S:”  aQ  0 m%U 4S2 jnS3T RR                  4S4T RT                  4S5T RV                  4S6U44 H  u  nnUc  M  UT%U'   M     U#U%U 4S7 jnOS8 nOT#" 5       nW" UUUS99T l-        T RZ                  R]                  5         T RZ                  R_                  5       nO,T R                   R                  S:5        URa                  U5      nURc                  U5        T(       a}   " U4S; jS<[d        5      n U " 5       n!URg                  U!5        TRi                  5         T Rj                  Rm                  S=S5      n"U!Rn                  (       a  U!Rn                  eU"(       a  U"egU$ ! [N         a    Sn GNäf = f)?aC  
Run the application component.

:param make: A factory that produces instances of :class:`autobahn.twisted.wamp.ApplicationSession`
   when called with an instance of :class:`autobahn.wamp.types.ComponentConfig`.
:param start_reactor: When ``True`` (the default) this method starts
   the Twisted reactor and doesn't return until the reactor
   stops. If there are any problems starting the reactor or
   connect()-ing, we stop the reactor and raise the exception
   back to the caller.
:param auto_reconnect:
:param log_level:
:param endpoint:
:param reactor:
:return: None is returned, unless you specify
    ``start_reactor=False`` in which case the Deferred that
    connect() returns is returned; this will callback() with
    an IProtocol instance, which will actually be an instance
    of :class:`WampWebSocketClientProtocol`
z{klass}.run()rN   r   ©rZ   )Úlevelc                  óü   >• [        TR                  TR                  TS9n  T" U 5      nU$ ! [         aE    TR                  R                  S5        T(       a!  TR                  (       a  TR                  5         e f = f)N)ÚrunnerzAApplicationSession could not be instantiated: {log_failure.value})r   r9   r:   Ú	Exceptionr.   ÚfailureÚrunningrT   )Úcfgr4   ÚmakerZ   rJ   rV   s     €€€€r1   ÚcreateÚ%ApplicationRunner.run.<locals>.createé   sg   ø€ Ü% d§j¡j°$·*±*ÀTÑJ�ð#Ù" 3›i�Gð #�Nøô !ó Ø—H‘H×$Ñ$Ð%hÔiÞ$¨¯¯ØŸ™œØð	ús
   ¢, ¬AA;ÚrsN)Ú
serializer)r8   r;   r=   r>   c                 óD   • [        U [        5      (       a  [        U 5      $ g ©N)Ú
isinstancer   r   )Úresponses    r1   ÚacceptÚ%ApplicationRunner.run.<locals>.accept  s!   € Ü˜hÔ(A×BÑBÜ:¸8ÓDÐDð Cr0   ÚversionÚutf8validateIncomingTÚacceptMaskedServerFramesFÚmaskClientFramesÚ	applyMaskÚmaxFramePayloadSizei   ÚmaxMessagePayloadSizeÚautoFragmentSizei   Ú
failByDropÚechoCloseCodeReasonÚserverConnectionDropTimeoutg      ð?ÚopenHandshakeTimeoutg      @ÚcloseHandshakeTimeoutÚ
tcpNoDelayÚperMessageCompressionOffersÚperMessageCompressionAcceptÚautoPingIntervalg      $@g      @é   )ÚautoPingTimeoutÚautoPingSizeÚautoPingRestartOnAnyTrafficzqssl= argument value passed to %s conflicts with the "ws:" prefix of the url argument. Did you mean to use "wss:"?©ÚoptionsForClientTLS)ÚTCP4ClientEndpointÚhostÚport)ÚSSL4ClientEndpointc                 ó(  • [        U S5      (       a�  U R                  bs  U R                  R                  5       (       a  U R                  R                  5       $ U R                  R	                  5       (       a  U R                  R                  5       $ g g g )NÚ_session)ÚhasattrrŒ   Úis_attachedÚleaveÚis_connectedÚ
disconnect)Úprotos    r1   ÚcleanupÚ&ApplicationRunner.run.<locals>.cleanup[  sr   € Ü�u˜j×)Ñ)¨e¯n©nÑ.HØ—>‘>×-Ñ-×/Ñ/Ø Ÿ>™>×/Ñ/Ó1Ð1Ø—^‘^×0Ñ0×2Ñ2Ø Ÿ>™>×4Ñ4Ó6Ð6ð 3ð /IÐ)r0   c                 óZ   >• T=R                   S-  sl         TR                  SSTU 5        U $ )Né   ÚbeforeÚshutdown)rI   ÚaddSystemEventTrigger)r’   r“   rZ   rJ   s    €€€r1   Ú
init_protoÚ)ApplicationRunner.run.<locals>.init_protod  s-   ø€ Ø×#Ò# qÑ(Õ#Ø×)Ñ)¨(°JÀÈÔOØˆLr0   )ÚClientService)ÚbackoffPolicyzusing t.a.i.ClientServicec                  ój   >• TR                   c  SOTR                   n [        R                  " 5       U -  $ )Nr–   )rD   Úrandom)ÚjrJ   s    €r1   Ú_jitterÚ&ApplicationRunner.run.<locals>._jitter|  s,   ø€ Ø!%×!8Ñ!8Ñ!@™AÀd×F]ÑF]˜Ü%Ÿ}š}›°Ñ2Ð2r0   ÚinitialDelayÚmaxDelayÚfactorÚjitterc                 ó¸   >• TR                   S:”  a.  TR                  S:X  d  U TR                  :  a  T" S0 TD6" U 5      $ [        S5        TR                  5         g)Nr   éÿÿÿÿzhit stopl    @ô Ìk r&   )rI   r@   ÚprintrT   )Úfailed_attemptsr�   ÚkwargsrJ   s    €€€r1   ÚretryÚ$ApplicationRunner.run.<locals>.retry‰  sU   ø€ Ø×2Ñ2°QÓ6¸D×<LÑ<LÐPRÓ<RÐVeÐhl×hxÑhxÓVxÙ#0Ñ#:°6Ò#:¸?Ó#KÐKä! *Ô-Ø ŸI™IœKØ#2r0   c                 ó   • g)Nr   r&   )Ú_s    r1   r¬   r­   ’  s   € Ø r0   )ÚretryPolicyzusing t.i.e.connect()c                   ó&   >• \ rS rSrSrU 4S jrSrg)Ú-ApplicationRunner.run.<locals>.ErrorCollectori­  Nc                 óH   >• UR                   U l        TR                  5         g rk   )ÚvalueÚ	exceptionrT   )rJ   rb   rZ   s     €r1   Ú__call__Ú6ApplicationRunner.run.<locals>.ErrorCollector.__call__°  s   ø€ Ø%,§]¡]�D”NØ—L‘L•Nr0   )rµ   )r'   r(   r)   r*   rµ   r¶   r/   r]   s   €r1   ÚErrorCollectorr²   ­  s   ø† Ø �	÷#ð #r0   r¸   Úerrorr&   )8r.   rP   rQ   r'   Útwisted.internetrZ   r,   Úuse_twistedÚconfigÚloopÚstart_loggingÚcallabler8   Ú
startswithÚparse_rs_urlr;   r   Úparse_ws_urlr   r=   r>   r   r   ÚDEFAULT_SPEC_VERSIONr?   ÚupdateÚsetProtocolOptionsÚnoisyr<   ÚRuntimeErrorÚtwisted.internet.sslr†   Útwisted.internet.endpointsr‡   ÚcontextFactoryrŠ   Útwisted.application.internetrœ   r�   ÚImportErrorr@   rA   rB   rC   rD   rH   ÚstartServiceÚwhenConnectedÚconnectÚaddCallbackÚobjectÚ
addErrbackÚrunr:   Úgetrµ   )&rJ   re   rV   rW   rX   rY   rZ   rf   ÚisSecurerˆ   r‰   ri   Útransport_factoryÚresourceÚpathÚparamsÚoffersrn   Úprotocol_optionsÚclientÚcontext_factoryr†   r‡   rŠ   rš   Úuse_servicerœ   r¡   ÚkeyÚvalr¬   Údr¸   Úconnect_errorÚ	app_errorr�   r“   r«   s&   ```   `                            @@@r1   rÓ   ÚApplicationRunner.runÄ   s  þ€ ð0 	�‰�‰�¨d¯n©n×.EÑ.EˆÑFæõ 1Ü×ÒÔØ 'ŒE�L‰LÔÜ×Ò iÒ0ä�D�>‰>÷
#ñ 
#ð ˆFà�8‰8×Ñ˜t×$Ñ$ä#/°·±Ó#9Ñ ˆH˜Dð 15×0@×0@˜×)Ñ)¨!Ò,ÀdˆJô !;¸6Ñ YÑô <HÈÏÉÓ;QÑ8ˆH˜D¨Dô !;¸6ÀtÇxÁxÐ]a×]mÑ]mÐuy×uÑuð  JN÷  JVñ  JVñ  !WÐô -Ó.Ð/ˆFòEð
 ØÔ,×AÑAð à&¨ð ð +¨Eð ð # Dð	 ð
 ˜Tð ð & wð ð (¨ð ð # Eð ð ˜dð ð & uð ð .¨rð ð '¨ð ð (¨ð ð ˜dð ð .¨vð ð  .¨vð! ð" # Cð# ð$ $&Ø "ð 04ò/ Ðð6 ×%×%Ø ×'Ñ'¨×(>Ñ(>Ô?ð ×0Ò0ÑDÐ3CÒDð #(ÐÔæØ‰Fð #ˆOØ�x‰xÑ#ÞÜ&ðRàŸ™×/Ñ/ñ0ó1ð 1ð #'§(¡(‘ÞÝDÙ"5°dÓ";�å0Ø�z‰zÑ%ÝIÙ+¨G°T·Z±ZÀÑ5GÈÏÉÐTZÑI[Ó\�Ø3BÐ!Õ0ÞÝIØ&Ñ2Ð2Ð2Ù+¨G°TÀÓQ‘åIÙ+¨G°TÓ@�ò
	7÷	ð
 ˆÞð$åFÝFØ"�÷ à�H‰H�N‰NÐ6Ô7à× Ñ Ñ,°×0HÑ0HÑ0TÐX\×XlÑXlÑXxð  }A÷  }Tñ  }Tñ  }`ð  dh÷  d{ñ  d{ñ  dGà×'Ñ'¨!Ó+Ø�Fõ3ð '5°d×6NÑ6NÐ%OØ&0°$×2FÑ2FÐ%GØ&.°×0GÑ0GÐ%HØ&.°Ð%8ó%:™˜˜Sð ›?Ø*-˜F 3›Kñ%:÷3ð 3ó!ñ &›�ñ $1°Ð9JÐX]Ñ#^ˆDÔ Ø× Ñ ×-Ñ-Ô/à×$Ñ$×2Ñ2Ó4‰Að �H‰H�N‰NÐ2Ô3à—‘Ð0Ó1ˆAð 	
�‰�jÔ!ö ÷
#¤ô #ñ +Ó,ˆMØ�L‰L˜Ô'ð �K‰KŒMð
 Ÿ
™
Ÿ™ w°Ó5ˆIð ×&×&Ø#×-Ñ-Ð-ÞØ�ð ð
 ˆHøôm ó $Ø#“ð$ús   ËR8 Ò8SÓS)rH   rI   r:   r>   rA   r@   rB   r=   r9   rC   rD   r;   r<   r8   r?   )NNNNNNNNNNNN)TFÚinfoNN)r'   r(   r)   r*   r+   r,   r-   r.   Ústrr   r   r   r   r   r   ÚintÚfloatrK   r   rT   Úboolr   r   r   rF   r   rÓ   r/   r&   r0   r1   r    r    l   s�  † ñð ×
Ò
Ó
€Cð )-Ø37Ø<@Ø59Ø37Ø59Ø?CØ.2Ø8<Ø48Ø7;Ø7;ñ>$Øð>$à  ™ð>$ð !  c¨3 h¡Ñ0ð>$ð ' t¨KÑ'8Ñ9ð	>$ð
 Ð1Ñ2ð>$ð !  c¨3 h¡Ñ0ð>$ð # 4¨¨S¨¡>Ñ2ð>$ð %-¨T°#°s°(©^Ñ$<ð>$ð ' s™mð>$ð '/¨u¡oð>$ð #+¨5¡/ð>$ð &.¨e¡_ð>$ð &.¨e¡_õ>$ð@ ñ	!ó ð	!ð ØKPØQUØ.2ñA tð AÀDð AØðAØ/7Ð8MÑ/NðAà˜lÑ+ðAà7<¹TÀ$»ZÈÐ=QÑ7RôAó óAr0   r    c                   ó^   • \ rS rSrSrS r\S 5       r\S 5       r\S 5       r	\S 5       r
Srg	)
Ú_ApplicationSessioniÉ  z`
WAMP application session class used internally with :class:`autobahn.twisted.app.Application`.
c                 ó:   • [         R                  X5        X l        g)zé

:param config: The component configuration.
:type config: Instance of :class:`autobahn.wamp.types.ComponentConfig`
:param app: The application this session is for.
:type app: Instance of :class:`autobahn.twisted.wamp.Application`.
N)r   rK   Úapp)rJ   r¼   rí   s      r1   rK   Ú_ApplicationSession.__init__Î  s   € ô 	×#Ñ# DÔ1Ø�r0   c              #   ó�   #   • U R                   R                  S5      v •  U R                  U R                  R                  5        g7f)z@
Implements :meth:`autobahn.wamp.interfaces.ISession.onConnect`
Ú	onconnectN)rí   Ú_fire_signalÚjoinr¼   r9   rS   s    r1   Ú	onConnectÚ_ApplicationSession.onConnectÚ  s2   é € ð
 �h‰h×#Ñ# KÓ0Ò0Ø�	‰	�$—+‘+×#Ñ#Õ$ùs   ‚AAc              #   ó  #   • U R                   R                   H  u  p#U R                  X25      v •  M     U R                   R                   H  u  p$U R	                  XB5      v •  M     U R                   R                  S5      v •  g7f)z=
Implements :meth:`autobahn.wamp.interfaces.ISession.onJoin`
ÚonjoinedN)rí   Ú_procsÚregisterÚ	_handlersÚ	subscriberñ   )rJ   ÚdetailsÚuriÚprocÚhandlers        r1   ÚonJoinÚ_ApplicationSession.onJoinâ  sh   é € ð
 Ÿ™Ÿœ‰IˆCØ—-‘- Ó*Ô*ñ )ð !ŸH™H×.Ô.‰LˆCØ—.‘. Ó.Ô.ñ /ð �h‰h×#Ñ# JÓ/Ó/ùs   ‚BBc              #   óf   #   • U R                   R                  S5      v •  U R                  5         g7f)z>
Implements :meth:`autobahn.wamp.interfaces.ISession.onLeave`
ÚonleaveN)rí   rñ   r‘   ©rJ   rû   s     r1   ÚonLeaveÚ_ApplicationSession.onLeaveï  s&   é € ð
 �h‰h×#Ñ# IÓ.Ò.Ø�‰Õùs   ‚/1c              #   óF   #   • U R                   R                  S5      v •  g7f)zC
Implements :meth:`autobahn.wamp.interfaces.ISession.onDisconnect`
ÚondisconnectN)rí   rñ   rS   s    r1   ÚonDisconnectÚ _ApplicationSession.onDisconnect÷  s   é € ð
 �h‰h×#Ñ# NÓ3Ó3ùs   ‚!)rí   N)r'   r(   r)   r*   r+   rK   r	   ró   rÿ   r  r  r/   r&   r0   r1   rë   rë   É  s\   † ñò
ð ñ%ó ð%ð ñ
0ó ð
0ð ñó ðð ñ4ó ó4r0   rë   c                   ó~   • \ rS rSrSr\R                  " 5       rSS jrS r	SS jr
SS jrSS jrS	 r\S
 5       rSrg)r!   iÿ  z‚
A WAMP application. The application object provides a simple way of
creating, debugging and running WAMP application components.
Nc                 óH   • Xl         / U l        / U l        0 U l        SU l        g)z…

:param prefix: The application URI prefix to use for procedures and topics,
   e.g. ``"com.example.myapp"``.
:type prefix: unicode
N)Ú_prefixr÷   rù   Ú_signalsr4   )rJ   Úprefixs     r1   rK   ÚApplication.__init__  s-   € ð Œð ˆŒð ˆŒð ˆŒð ˆ�r0   c                 óX   • U R                   b   e[        X5      U l         U R                   $ )a  
Factory creating a WAMP application session for the application.

:param config: Component configuration.
:type config: Instance of :class:`autobahn.wamp.types.ComponentConfig`

:returns: obj -- An object that derives of
   :class:`autobahn.twisted.wamp.ApplicationSession`
)r4   rë   )rJ   r¼   s     r1   r¶   ÚApplication.__call__  s*   € ð �|‰|Ñ#Ð$Ð#Ü*¨6Ó8ˆŒØ�|‰|Ðr0   c                 óP   • [        X5      nUR                  U R                  U5      $ )z©
Run the application.

:param url: The URL of the WAMP router to connect to.
:type url: unicode
:param realm: The realm on the WAMP router to join.
:type realm: unicode
)r    rÓ   r¶   )rJ   r8   r9   rV   r`   s        r1   rÓ   ÚApplication.run*  s#   € ô # 3Ó.ˆØ�z‰z˜$Ÿ-™-¨Ó7Ð7r0   c                 ó   ^ ^• U U4S jnU$ )ab  
Decorator exposing a function as a remote callable procedure.

The first argument of the decorator should be the URI of the procedure
to register under.

:Example:

.. code-block:: python

   @app.register('com.myapp.add2')
   def add2(a, b):
      return a + b

Above function can then be called remotely over WAMP using the URI `com.myapp.add2`
the function was registered under.

If no URI is given, the URI is constructed from the application URI prefix
and the Python function name.

:Example:

.. code-block:: python

   app = Application('com.myapp')

   # implicit URI will be 'com.myapp.add2'
   @app.register()
   def add2(a, b):
      return a + b

If the function `yields` (is a co-routine), the `@inlineCallbacks` decorator
will be applied automatically to it. In that case, if you wish to return something,
you should use `returnValue`:

:Example:

.. code-block:: python

   from twisted.internet.defer import returnValue

   @app.register('com.myapp.add2')
   def add2(a, b):
      res = yield stuff(a, b)
      returnValue(res)

:param uri: The URI of the procedure to register under.
:type uri: unicode
c                 ó
  >• T(       a  TnO5TR                   c   eSR                  TR                   U R                  5      n[        R                  " U 5      (       a  [        U 5      n TR                  R                  X45        U $ ©Nz{0}.{1})r  Úformatr'   ÚinspectÚisgeneratorfunctionr	   r÷   Úappend©ÚfuncÚ_urirJ   rü   s     €€r1   Ú	decoratorÚ'Application.register.<locals>.decoratorh  si   ø€ ÞØ‘à—|‘|Ñ/Ð0Ð/Ø ×'Ñ'¨¯©°d·m±mÓD�ä×*Ò*¨4×0Ñ0Ü& tÓ,�à�K‰K×Ñ ˜|Ô,ØˆKr0   r&   ©rJ   rü   r  s   `` r1   rø   ÚApplication.register6  s   ù€ öd	ð Ðr0   c                 ó   ^ ^• U U4S jnU$ )a;  
Decorator attaching a function as an event handler.

The first argument of the decorator should be the URI of the topic
to subscribe to. If no URI is given, the URI is constructed from
the application URI prefix and the Python function name.

If the function yield, it will be assumed that it's an asynchronous
process and inlineCallbacks will be applied to it.

:Example:

.. code-block:: python

   @app.subscribe('com.myapp.topic1')
   def onevent1(x, y):
      print("got event on topic1", x, y)

:param uri: The URI of the topic to subscribe to.
:type uri: unicode
c                 ó
  >• T(       a  TnO5TR                   c   eSR                  TR                   U R                  5      n[        R                  " U 5      (       a  [        U 5      n TR                  R                  X45        U $ r  )r  r  r'   r  r  r	   rù   r  r  s     €€r1   r  Ú(Application.subscribe.<locals>.decoratorŒ  si   ø€ ÞØ‘à—|‘|Ñ/Ð0Ð/Ø ×'Ñ'¨¯©°d·m±mÓD�ä×*Ò*¨4×0Ñ0Ü& tÓ,�à�N‰N×!Ñ! 4 ,Ô/ØˆKr0   r&   r   s   `` r1   rú   ÚApplication.subscribev  s   ù€ ö,	ð Ðr0   c                 ó   ^ ^• UU 4S jnU$ )a
  
Decorator attaching a function as handler for application signals.

Signals are local events triggered internally and exposed to the
developer to be able to react to the application lifecycle.

If the function yield, it will be assumed that it's an asynchronous
coroutine and inlineCallbacks will be applied to it.

Current signals :

   - `onjoined`: Triggered after the application session has joined the
      realm on the router and registered/subscribed all procedures
      and event handlers that were setup via decorators.
   - `onleave`: Triggered when the application session leaves the realm.

.. code-block:: python

   @app.signal('onjoined')
   def _():
      # do after the app has join a realm

:param name: The name of the signal to watch.
:type name: unicode
c                 óª   >• [         R                  " U 5      (       a  [        U 5      n TR                  R	                  T/ 5      R                  U 5        U $ rk   )r  r  r	   r  Ú
setdefaultr  )r  ÚnamerJ   s    €€r1   r  Ú%Application.signal.<locals>.decorator´  sB   ø€ Ü×*Ò*¨4×0Ñ0Ü& tÓ,�Ø�M‰M×$Ñ$ T¨2Ó.×5Ñ5°dÔ;ØˆKr0   r&   )rJ   r)  r  s   `` r1   ÚsignalÚApplication.signalš  s   ù€ ö4	ð
 Ðr0   c              /   óÌ   #   • U R                   R                  U/ 5       H  n U" U0 UD6v •  M     g! [         a%  nU R                  R	                  SUS9   SnAM=  SnAff = f7f)zo
Utility method to call all signal handlers for a given signal.

:param name: The signal name.
:type name: str
z5Warning: exception in signal handler swallowed: {err})ÚerrN)r  rÔ   ra   r.   rå   )rJ   r)  Úargsr«   rþ   Úes         r1   rñ   ÚApplication._fire_signal»  sc   é € ð —}‘}×(Ñ(¨¨rÖ2ˆGð^ñ ˜tÐ. vÑ.Ô.ò	 3øô
 ó ^à—‘—‘ÐUÐ[\�×]ûð^üs*   ‚ A$£
2­A$²
A!¼AÁA$ÁA!Á!A$)rù   r  r÷   r  r4   rk   )zws://localhost:8080/wsÚrealm1T)r'   r(   r)   r*   r+   r,   r-   r.   rK   r¶   rÓ   rø   rú   r+  r	   rñ   r/   r&   r0   r1   r!   r!   ÿ  sN   † ñð
 ×
Ò
Ó
€Côò*ô
8ô>ô@"òHðB ñ^ó ó^r0   r!   c                   ó,   • \ rS rSrSr\rSS jrS rSr	g)r"   iÍ  aæ  
A WAMP application as a twisted service.
The application object provides a simple way of creating, debugging and running WAMP application
components inside a traditional twisted application

This manages application lifecycle of the wamp connection using startService and stopService
Using services also allows to create integration tests that properly terminates their connections

It can host a WAMP application component in a WAMP-over-WebSocket client
connecting to a WAMP router.
Nc                 óÂ   • Xl         X l        U=(       d
    [        5       U l        X0l        XPl        [        R                  R                  U 5        U R                  5         g)aã  

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

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

: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 extra: Optional extra configuration to forward to the application component.
:type extra: dict

:param context_factory: optional, only for secure connections. Passed as contextFactory to
    the ``listenSSL()`` call; see https://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IReactorSSL.connectSSL.html
:type context_factory: twisted.internet.ssl.ClientContextFactory or None

You can replace the attribute factory in order to change connectionLost or connectionFailed behaviour.
The factory attribute must return a WampWebSocketClientFactory object
N)
r8   r9   rG   r:   re   rÝ   r   ÚMultiServicerK   ÚsetupService)rJ   r8   r9   re   r:   rÝ   s         r1   rK   ÚService.__init__Û  sF   € ð. ŒØŒ
Ø—_œd›fˆŒ
ØŒ	Ø.ÔÜ×Ñ×%Ñ% dÔ+Ø×ÑÕr0   c                 óL  ^ • [        T R                  5      u  pp4pVU 4S jnT R                  UT R                  S9nU(       a+  SSKJn	  T R
                  n
U
c  SSKJn  U" U5      n
U	" X#XŠS9nO'T R
                  b  [        S5      eSS	KJ	n  U" X#U5      nUR                  T 5        g)
z"
Setup the application component.
c                  ój   >• [        TR                  TR                  5      n TR                  U 5      nU$ rk   )r   r9   r:   re   )rd   r4   rJ   s     €r1   rf   Ú$Service.setupService.<locals>.create  s)   ø€ Ü! $§*¡*¨d¯j©jÓ9ˆCØ—i‘i “nˆGØˆNr0   )r8   r   )Ú	SSLClientNr…   )rÊ   z+context_factory specified on non-secure URI)Ú	TCPClient)rÂ   r8   ÚfactoryrË   r;  rÝ   rÈ   r†   ra   r<  ÚsetServiceParent)rJ   Ú	is_securerˆ   r‰   r×   rØ   rÙ   rf   rÖ   r;  Úctxr†   rÜ   r<  s   `             r1   r6  ÚService.setupServiceú  s¡   ø€ ô 9EÀTÇXÁXÓ8NÑ5ˆ	˜¨õ	ð !ŸL™L¨°T·X±X˜LÐ>Ðö Ý>Ø×&Ñ&ˆCØ‰{ÝDÙ)¨$Ó/�Ù˜tÐ+<ÑQ‰Fà×#Ñ#Ñ/ÜÐ MÓNÐNÝ>Ù˜tÐ+<Ó=ˆFà×Ñ Õ%r0   )rÝ   r:   re   r9   r8   )NN)
r'   r(   r)   r*   r+   r   r=  rK   r6  r/   r&   r0   r1   r"   r"   Í  s   † ñ
ð )€Gôõ>&r0   r"   c                   ó2   • \ rS rSrS rS rS rS rS rSr	g)	r#   i  c                 ó   • g rk   r&   )rJ   Úwelcome_msgs     r1   Ú
on_welcomeÚSession.on_welcome   ó   € Ør0   c                 ó   • g rk   r&   r  s     r1   Úon_joinÚSession.on_join#  rG  r0   c                 ó$   • U R                  5         g rk   )r‘   r  s     r1   Úon_leaveÚSession.on_leave&  s   € Ø�‰Õr0   c                 óN   • U R                  U R                  R                  5        g rk   )rò   r¼   r9   rS   s    r1   Ú
on_connectÚSession.on_connect)  s   € Ø�	‰	�$—+‘+×#Ñ#Õ$r0   c                 ó   • g rk   r&   rS   s    r1   Úon_disconnectÚSession.on_disconnect,  rG  r0   r&   N)
r'   r(   r)   r*   rE  rI  rL  rO  rR  r/   r&   r0   r1   r#   r#     s   † òòòò%õr0   r#   c                   ó    • \ rS rSrS rS rSrg)ÚAuthCryptoSigni1  c                 óö  • UR                  5        H7  nUS;  d  M  [        SR                  X R                  R                  5      5      e   S H"  nX!;  d  M
  [        SR                  U5      5      e   UR                  S[        5       5       H#  nUS;  d  M  [        SR                  U5      5      e   SS	KJn  UR                  [        R                  " US
   5      5      U l        SUR                  S[        5       5      ;   a1  US   S   nX@R                  R                  5       :w  a  [        S5      eO=UR                  S[        5       5      US'   U R                  R                  5       US   S'   Xl        g )N)Ú	authextraÚauthidÚauthroleÚprivkeyúUnexpected key '{}' for {})rZ  z Must provide '{}' for cryptosignrW  )ÚpubkeyÚchannel_bindingÚ	trustrootÚ	challengez"Unexpected key '{}' in 'authextra'r   )ÚCryptosignKeyrZ  r\  z,Public key doesn't correspond to private key)ÚkeysÚ
ValueErrorr  rQ   r'   rÔ   rG   Úautobahn.wamp.cryptosignr`  Ú
from_bytesÚbinasciiÚa2b_hexÚ_privkeyÚ
public_keyÚ_args)rJ   Úkwrß   r`  r\  s        r1   rK   ÚAuthCryptoSign.__init__3  sW  € à—7‘7–9ˆCØÐHÕHÜ Ø0×7Ñ7¸¿^¹^×=TÑ=TÓUóð ñ ó
 ˆCØ�}Ü Ø6×=Ñ=¸cÓBóð ñ ð
 —6‘6˜+¤t£vÖ.ˆCØÐQÕQÜ Ø8×?Ñ?ÀÓDóð ñ /õ 	;Ø%×0Ñ0Ü×Ò˜R 	™]Ó+ó
ˆŒð �r—v‘v˜k¬4«6Ó2Ó2Ø˜‘_ XÑ.ˆFØŸ™×1Ñ1Ó3Ó3Ü ØBóð ð 4ð
 !Ÿf™f [´$³&Ó9ˆBˆ{‰OØ(,¯©×(@Ñ(@Ó(BˆBˆ{‰O˜HÑ%Ø�
r0   c                 óØ   • U R                   S   R                  SS 5      nU R                  R                  R                  R                  US 5      nU R
                  R                  X$US9nU$ )NrW  r]  )Ú
channel_idÚchannel_id_type)ri  rÔ   Ú	transportÚtransport_detailsrm  rg  Úsign_challenge)rJ   r4   r_  rn  rm  Úsigned_challenges         r1   Úon_challengeÚAuthCryptoSign.on_challengeU  sg   € àŸ*™* [Ñ1×5Ñ5Ð6GÈÓNˆØ—^‘^×5Ñ5×@Ñ@×DÑDÀ_ÐVZÓ[ˆ
ØŸ=™=×7Ñ7¸	ØHWð 8ð YÐàÐr0   )ri  rg  N©r'   r(   r)   r*   rK   rs  r/   r&   r0   r1   rU  rU  1  s   † ò õD r0   rU  c                   ó    • \ rS rSrS rS rSrg)ÚAuthWampCraia  c                 ó¢  • UR                  5        H7  nUS;  d  M  [        SR                  X R                  R                  5      5      e   S H"  nX!;  d  M
  [        SR                  U5      5      e   Xl        UR                  S5      U l        [        U R                  [        5      (       d!  U R                  R                  S5      U l        g g )N)rW  rX  rY  Úsecretr[  )ry  rX  zMust provide '{}' for wampcrary  Úutf8)ra  rb  r  rQ   r'   ri  ÚpopÚ_secretrl   ræ   Údecode)rJ   rj  rß   s      r1   rK   ÚAuthWampCra.__init__c  s¯   € à—7‘7–9ˆCØÐGÕGÜ Ø0×7Ñ7¸¿^¹^×=TÑ=TÓUóð ñ ó
 (ˆCØ�}Ü Ø3×:Ñ:¸3Ó?óð ñ (ð Œ
Ø—v‘v˜hÓ'ˆŒÜ˜$Ÿ,™,¬×,Ñ,ØŸ<™<×.Ñ.¨vÓ6ˆD�Lð -r0   c                 ó`  • U R                   R                  S5      nSUR                  ;   a@  [        R                  " UUR                  S   UR                  S   UR                  S   5      n[        R
                  " UUR                  S   R                  S5      5      nUR                  S5      $ )Nrz  ÚsaltÚ
iterationsÚkeylenr_  Úascii)r|  Úencoder:   r   Ú
derive_keyÚcompute_wcsr}  )rJ   r4   r_  rß   Ú	signatures        r1   rs  ÚAuthWampCra.on_challengeu  s–   € Ø�l‰l×!Ñ! &Ó)ˆØ�Y—_‘_Ó$Ü—/’/ØØ—‘ Ñ'Ø—‘ Ñ-Ø—‘ Ñ)ó	ˆCô ×$Ò$ØØ�O‰O˜KÑ(×/Ñ/°Ó7ó
ˆ	ð ×Ñ Ó(Ð(r0   )ri  r|  Nru  r&   r0   r1   rw  rw  a  s   † ò7õ$)r0   rw  )Ar  re  rŸ   Útypingr   r   r   r   r   r,   Úautobahn.websocket.protocolr   r»   Útwisted.internet.deferr	   r
   r   Útwisted.applicationr   Útwisted.internet.interfacesr   r   rÈ   r   rÌ   Úautobahn.utilr   Úautobahn.websocket.utilr   rÂ   Úautobahn.rawsocket.utilrÁ   Úautobahn.twisted.websocketr   Úautobahn.twisted.rawsocketr   Úautobahn.websocket.compressr   r   r   Úautobahn.wampr   r   Úautobahn.wamp.interfacesr   r   r   r   Úautobahn.wamp.typesr   Ú__all__r   rø   Úabc_registerr   rÑ   r    rë   r!   r5  r"   Ú_SessionShimr#   rU  rw  r&   r0   r1   Ú<module>rš     sx  ðó6 Û Û ß 3Õ 3ã Ý 9à × Ò Ô ç EÑ EÝ 'ß KðÝ7õ
 !å =Ý =å AÝ A÷?ñ ?÷ )ß ]Ó ]Ý /ò
€ð ô
˜×4Ñ4ó 
ó ð
ð × Ò Ð-Ô .ð 	× Ò Ð(Ô )ô
 × BÑ Bô 
ð ôY˜ó Yó ðYôx
34Ð,ô 34ôlK^�&ô K^ô\K&ˆg×"Ñ"ô K&ô^ˆh×#Ñ#ô ô** �Vô * ðZ × Ò ˜Ô 'ô")�&ô ")ðJ × Ò ˜Õ $øðw ó àÓðús   ÁE9 Å9FÆF