ó
    ð›‘hQ'  ã                   ó”  •  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
   S SK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r\" \5       " S S\5      5       r\" \
5       " S S\5      5       r " S S\\5      r " S S\5      r " S S\5      rS r S r!g! \ a	    \" S5      ef = f! \ a	    S SKJr   N�f = f)é    )ÚIHostnameResolverz=Twisted 17.1.0 or later required for autobahn.twisted.testing)ÚDeferred)ÚIPv4Address)ÚHostResolution)ÚISSLTransportÚIReactorPluggableNameResolver)ÚMemoryReactorClock)Úiosim)ÚdirectlyProvidesÚimplementer)ÚIWebSocketClientAgent)Ú_TwistedWebSocketClientAgent)ÚWebSocketServerProtocol)ÚWebSocketServerFactory)Úcreate_pumperÚcreate_memory_agentÚMemoryReactorClockResolverc                   ó   • \ rS rSrSS jrSrg)Ú_StaticTestResolveré>   c                 ó¤   • [        U5      nUR                  U5        UR                  [        SSUS:X  a  SOU5      5        UR	                  5         g)zB
Implement IHostnameResolver which always returns 127.0.0.1:31337
ÚTCPú	127.0.0.1r   éiz  N)r   ÚresolutionBeganÚaddressResolvedr   ÚresolutionComplete)ÚselfÚreceiverÚhostNameÚ
portNumberÚ
resolutions        ÚeC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\autobahn/twisted/testing/__init__.pyÚresolveHostNameÚ#_StaticTestResolver.resolveHostName@   sL   € ô $ HÓ-ˆ
Ø× Ñ  Ô,Ø× Ñ Ü˜˜{°ZÀ1³_©EÈ*ÓUô	
ð 	×#Ñ#Õ%ó    © N)r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r$   Ú__static_attributes__r'   r&   r#   r   r   >   s   † ÷	&r&   r   c                   ó2   • \ rS rSrSrSr\S 5       rS rSr	g)Ú_TestNameResolveréL   z1
A test version of IReactorPluggableNameResolver
Nc                 óR   • U R                   c  [        5       U l         U R                   $ ©N)Ú	_resolverr   ©r   s    r#   ÚnameResolverÚ_TestNameResolver.nameResolverT   s    € à�>‰>Ñ!Ü0Ó2ˆDŒNØ�~‰~Ðr&   c                 ó*   • U R                   nXl         U$ r1   ©r2   )r   ÚresolverÚolds      r#   ÚinstallNameResolverÚ%_TestNameResolver.installNameResolverZ   s   € Ø�n‰nˆØ!ŒØˆ
r&   r7   )
r(   r)   r*   r+   Ú__doc__r2   Úpropertyr4   r:   r,   r'   r&   r#   r.   r.   L   s%   † ñð €Iàñó ðõ
r&   r.   c                   ó   • \ rS rSrSrSrg)r   é`   zM
Combine MemoryReactor, Clock and an IReactorPluggableNameResolver
together.
r'   N)r(   r)   r*   r+   r<   r,   r'   r&   r#   r   r   `   s   † ñò 	r&   r   c                   ó(   • \ rS rSrSrS rSS jrSrg)Ú_TwistedWebMemoryAgentéh   a¼  
A testing agent which will hook up an instance of
`server_protocol` for every client that is created via the `open`
API call.

:param reactor: the reactor to use for tests (usually an instance
    of MemoryReactorClockResolver)

:param pumper: an implementation IPumper (e.g. as returned by
    `create_pumper`)

:param server_protocol: the server-side WebSocket protocol class
    to instantiate (e.g. a subclass of `WebSocketServerProtocol`
c                 ó˜   • Xl         X0l        X l        [        U R                   5      U l        [        5       U l        [        5       U l        g r1   )	Ú_reactorÚ_server_protocolÚ_pumperr   Ú_agentÚsetÚ_pumpsÚdictÚ_servers)r   ÚreactorÚpumperÚserver_protocols       r#   Ú__init__Ú_TwistedWebMemoryAgent.__init__x   s6   € ØŒØ /ÔØŒô 3°4·=±=ÓAˆŒÜ“eˆŒÜ›ˆ�r&   Nc                 óÐ  ^ ^• UR                  S5      nT R                  R                  XUS9nU(       a  T R                  R                  S   u  pgp‰p«OT R                  R
                  S   u  pgpŠn[        SSU5      n[        SSS5      nT R                  5       m[        TSS5      c  [        5       Tl
        [        R                  " TS	XÍS
9nUR                  S5      n[        R                  " USXÜS
9nU(       a   [        U[        5        [        U[        5        [        R                   " TXïU5      nT R"                  R%                  U5        U U4S jnUR'                  U5        U$ )a=  
Implement IWebSocketClientAgent with in-memory transports.

:param transport_config: a string starting with 'wss://' or
    'ws://'

:param options: a dict containing options

:param protocol_class: the client protocol class to
    instantiate (or `None` for defaults, which is to use
    `WebSocketClientProtocol`)
zwss://)Úprotocol_classéÿÿÿÿr   r   r   ÚfactoryNT)ÚisServerÚhostAddressÚpeerAddressFc                 ó&   >• TTR                   U '   U $ r1   )rK   )Úprotor   rN   s    €€r#   Úadd_mappingÚ0_TwistedWebMemoryAgent.open.<locals>.add_mapping´   s   ø€ Ø#2ˆD�M‰M˜%Ñ ØˆLr&   )Ú
startswithrG   ÚopenrD   Ú
sslClientsÚ
tcpClientsr   rE   Úgetattrr   rT   r
   ÚFakeTransportÚbuildProtocolr   r   ÚconnectrF   ÚaddÚaddCallback)r   Útransport_configÚoptionsrR   Ú	is_secureÚreal_client_protocolÚhostÚportrT   Úcontext_factoryÚtimeoutÚbindAddressÚserver_addressÚclient_addressÚserver_transportÚclientProtocolÚclient_transportÚpumprZ   rN   s   `                  @r#   r]   Ú_TwistedWebMemoryAgent.open‚   s`  ù€ ð %×/Ñ/°Ó9ˆ	ð  $Ÿ{™{×/Ñ/ØØ)ð  0ð  
Ðö
 ØIMÏÉ×IaÑIaÐbdÑIeÑFˆD˜°'¸;à8<¿¹×8PÑ8PÐQSÑ8TÑ5ˆD˜¨+ä$ U¨K¸Ó>ˆÜ$ U¨K¸Ó?ˆà×/Ñ/Ó1ˆä�? I¨tÓ4Ñ<Ü&<Ó&>ˆOÔ#ä ×.Ò.Ø dØ&ñDÐð !×.Ñ.¨tÓ4ˆÜ ×.Ò.Ø UØ&ñDÐö ÜÐ-¬}Ô=ÜÐ-¬}Ô=ä�}Š}ØÐ-Ð?OóQˆà�‰×Ñ˜Ôö	ð 	×(Ñ(¨Ô5Ø#Ð#r&   )rG   rF   rI   rD   rE   rK   r1   )r(   r)   r*   r+   r<   rO   r]   r,   r'   r&   r#   rA   rA   h   s   † ñò÷6$r&   rA   c                   ó<   • \ rS rSrSrS rS rS rS rS r	S r
S	rg
)Ú
_Kalamazooé»   a�  
Feeling whimsical about class names, see https://en.wikipedia.org/wiki/Handcar

This is 'an IOPump pumper', an object which causes a series of
IOPumps it is monitoring to do their I/O operations
periodically. This needs the 'real' reactor which trial drives,
because reasons:

 - so @inlineCallbacks / async-def functions work
   (if I could explain exactly why here, I would)

 - we need to 'break the loop' of synchronous calls somewhere and
   polluting the tests themselves with that is bad

 - get rid of e.g. .flush() calls in tests themselves (thus
  'teaching' the tests about details of I/O scheduling that they
  shouldn't know).
c                 óV   • [        5       U l        SU l        / U l        SSKJn  Xl        g )NFr   )rL   )rH   rI   Ú_pumpingÚ_waiting_for_stopÚtwisted.internetrL   Ú_global_reactor)r   Úglobal_reactors     r#   rO   Ú_Kalamazoo.__init__Ï   s#   € Ü“eˆŒØˆŒØ!#ˆÔÝ>Ø-Õr&   c                 ó:   • U R                   R                  U5        g)zX
Add a new IOPump. It will be removed when both its client and
server are disconnected.
N)rI   rd   )r   Úps     r#   rd   Ú_Kalamazoo.addÖ   s   € ð
 	�‰�‰˜Õr&   c                 ó‚   • U R                   (       a  gSU l         U R                  R                  SU R                  5        g)z£
Begin triggering I/O in all IOPump instances we have. We will keep
periodically 'pumping' our IOPumps until `.stop()` is
called. Call from `setUp()` for example.
NTr   )rz   r}   Ú	callLaterÚ
_pump_oncer3   s    r#   ÚstartÚ_Kalamazoo.startÝ   s/   € ð �=�=ØØˆŒØ×Ñ×&Ñ& q¨$¯/©/Õ:r&   c                 óî   • U R                   (       d  [        U R                  5      (       a.  [        5       nU R                  R	                  U5        SU l         U$ [        5       nUR                  S5        U$ )zg
:returns: a Deferred that fires when we have stopped pump()-ing

Call from `tearDown()`, for example.
FN)rz   Úlenr{   r   ÚappendÚcallback©r   Úds     r#   ÚstopÚ_Kalamazoo.stopè   sZ   € ð �=�=œC × 6Ñ 6×7Ñ7Ü“
ˆAØ×"Ñ"×)Ñ)¨!Ô,Ø!ˆDŒMØˆHÜ‹JˆØ	�
‰
�4ÔØˆr&   c                 óê   • U R                   (       a7  U R                  5         U R                  R                  SU R                  5        gU R
                   H  nUR                  S5        M     / U l        g)zc
flush all data from all our IOPump instances and schedule another
iteration on the global reactor
gš™™™™™¹?N)rz   Ú_flushr}   r„   r…   r{   r‹   rŒ   s     r#   r…   Ú_Kalamazoo._pump_once÷   sR   € ð
 �=�=Ø�K‰KŒMØ× Ñ ×*Ñ*¨3°·±Õ@à×+Ô+�Ø—
‘
˜4Ö ñ ,à%'ˆDÕ"r&   c                 ó   • U R                   n[        5       =o l         U H\  nUR                  5         UR                  R                  (       a  UR
                  R                  (       a  MK  UR                  U5        M^     g)z5
Flush all data between pending client/server pairs.
N)rI   rH   ÚflushÚclientIOÚdisconnectedÚserverIOrd   )r   Ú	old_pumpsÚ	new_pumpsr�   s       r#   r‘   Ú_Kalamazoo._flush  sT   € ð —K‘Kˆ	Ü"%£%Ð'ˆ	”KÛˆAØ�G‰GŒIØ�z‰z×&×&¨1¯:©:×+B×+BÙØ�M‰M˜!Öò	 r&   )r}   rz   rI   r{   N)r(   r)   r*   r+   r<   rO   rd   r†   rŽ   r…   r‘   r,   r'   r&   r#   rw   rw   »   s%   † ñò&.òò	;òò(õ
r&   rw   c                  ó   • [        5       $ )z,
return a new instance implementing IPumper
)rw   r'   r&   r#   r   r     s   € ô ‹<Ðr&   c                 ó,   • Uc  [         n[        XU5      $ )a  
return a new instance implementing `IWebSocketClientAgent`.

connection attempts will be satisfied by traversing the Upgrade
request path starting at `resource` to find a `WebSocketResource`
and then exchange data between client and server using purely
in-memory buffers.
)r   rA   )rL   rM   rN   s      r#   r   r     s   € ð ÑÜ1ˆÜ! '°?ÓCÐCr&   N)"Útwisted.internet.interfacesr   ÚImportErrorÚtwisted.internet.deferr   Útwisted.internet.addressr   Útwisted.internet._resolverr   r   r   Útwisted.internet.testingr	   Útwisted.test.proto_helpersÚtwisted.testr
   Úzope.interfacer   r   Úautobahn.websocket.interfacesr   Úautobahn.twisted.websocketr   r   r   Ú__all__Úobjectr   r.   r   rA   rw   r   r   r'   r&   r#   Ú<module>rª      sï   ðð<Ý=õ ,Ý 0Ý 5ß Tð>Ý;õ ç 8å ?Ý CÝ >Ý =ð€ñ ÐÓô
&˜&ó 
&ó  ð
&ñ Ð*Ó+ô˜ó ó ,ðô&	Ð!3Ð5Fô 	ôP$Ð2ô P$ôfS�ô SòlóDøðq ó Ù
ØGóð ðûð ó >ß=ð>ús   ‚B& £B8 Â&B5Â8CÃC