+
    i\V              (         ^ RI Ht ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
HtHtHtHt ^RIHt ^RIHt ^RIHtHtHt ^RIHt ^R	IHt ^R
IHt ^RIHtHt ^RI H!t!H"t" ^RI#H$t$H%t%H&t&H't' ^RI(H)t) ^RI	H*t*H+t+H,t,H-t- ^RI.H/t/H0t0 ^RI1H2t2 ^RI3H4t4 . RDOt5 ! R R]24      t6RRRRRRRRRRRRRRRRR]RR R!RR"RR#^
R$^R%^R&^
R'RER(^R)RR*R/R+ R, llt7RFR- R. llt8 ^ R/I9H:t: ^ R0I;H$t< R1]:Pz                  R2]:Pz                  R3]:P|                  R4]:P|                  /t?R1R R2R5R3R R4R5/t@R6 R7 ltAR: R; ltCRRRRRR/R< R= lltD]! R>4      tE]! R?]R@]E3,          RA7      tF ! RB RC4      tGR#   ]B d
    R8 R9 ltA LJi ; i)G    )annotationsN)Sequence)AnyCallableLiteralTypeVarcast)ClientProtocol)HeadersLike)InvalidProxyMessageInvalidProxyStatus
ProxyError)ClientExtensionFactory) enable_client_permessage_deflate)validate_subprotocols)
USER_AGENTResponse)
CONNECTINGEvent)Proxy	get_proxyparse_proxyprepare_connect_request)StreamReader)	BytesLike
LoggerLikeOriginSubprotocol)WebSocketURI	parse_uri)
Connection)DeadlineClientConnectionc                     a  ] tR t^tRtR^R^R^
R^/R V 3R llltR]R3R	 R
 lltR V 3R lltR V 3R llt	Rt
V ;t# )r#   a  
:mod:`threading` implementation of a WebSocket client connection.

:class:`ClientConnection` provides :meth:`recv` and :meth:`send` methods for
receiving and sending messages.

It supports iteration to receive messages::

    for message in websocket:
        process(message)

The iterator exits normally when the connection is closed with code
1000 (OK) or 1001 (going away) or without a close code. It raises a
:exc:`~websockets.exceptions.ConnectionClosedError` when the connection is
closed with any other code.

The ``ping_interval``, ``ping_timeout``, ``close_timeout``, and
``max_queue`` arguments have the same meaning as in :func:`connect`.

Args:
    socket: Socket connected to a WebSocket server.
    protocol: Sans-I/O connection.

ping_intervalping_timeoutclose_timeout	max_queuec               4    V ^8  d   QhRRRRRRRRRRR	R
RR/# )   socketsocket.socketprotocolr
   r%   float | Noner&   r'   r(   *int | None | tuple[int | None, int | None]returnNone )formats   "]/home/wkmabra/.openclaw/workspace/venv/lib/python3.14/site-packages/websockets/sync/client.py__annotate__ClientConnection.__annotate__7   sP     
 

 !

 $
 #
 $
 >
 

    c          	     	j   < V  \         P                  ! 4       V n        \        SV `  VVVVVVR 7       R# )r%   r&   r'   r(   N)	threadingr   response_rcvdsuper__init__)selfr+   r-   r%   r&   r'   r(   	__class__s   &&&$$$$r4   r=   ClientConnection.__init__7   s;     	&__.'%' 	 	
r7   Nc               (    V ^8  d   QhRRRRRRRR/# )	r*   additional_headersHeadersLike | Noneuser_agent_header
str | Nonetimeoutr.   r0   r1   r2   )r3   s   "r4   r5   r6   L   s2     . ... &. 	.
 
.r7   c                \   V P                  \        R7      ;_uu_ 4        V P                  P                  4       V n        Ve&   V P                  P
                  P                  V4       Ve'   V P                  P
                  P                  RV4       V P                  P                  V P                  4       RRR4       V P                  P                  V4      '       g   \        R4      hV P                  P                  e   V P                  P                  hR#   + '       g   i     Ll; i)z!
Perform the opening handshake.

)expected_stateNz
User-Agentz.timed out while waiting for handshake response)send_contextr   r-   connectrequestheadersupdate
setdefaultsend_requestr;   waitTimeoutErrorhandshake_exc)r>   rB   rD   rF   s   &&&&r4   	handshakeClientConnection.handshakeL   s     j99==002DL!-$$++,>? ,$$//>OPMM&&t||4 : !!&&w//OPP ==&&2----- 3 :9s   BDD+	c                    V ^8  d   QhRRRR/# )r*   eventr   r0   r1   r2   )r3   s   "r4   r5   r6   h   s     ) )5 )T )r7   c                   < V P                   f;   \        V\        4      '       g   Q hWn         V P                  P	                  4        R# \
        SV `  V4       R# )z
Process one incoming event.

N)response
isinstancer   r;   setr<   process_event)r>   rV   r?   s   &&r4   r[   ClientConnection.process_eventh   sH     == eX....!M""$ G!%(r7   c                   V ^8  d   QhRR/# )r*   r0   r1   r2   )r3   s   "r4   r5   r6   v   s     	% 	%T 	%r7   c                   <  \         SV `  4        V P                  P                  4        R#   T P                  P                  4        i ; i)z9
Read incoming data from the socket and process events.

N)r<   recv_eventsr;   rZ   )r>   r?   s   &r4   r_   ClientConnection.recv_eventsv   s:    
	%G! ""$D""$s	   - A	)rK   rX   r;   )__name__
__module____qualname____firstlineno____doc__r=   r   rS   r[   r_   __static_attributes____classcell__)r?   s   @r4   r#   r#      s`    2

 ')
 &(
 ')
 AC
 
. 26(2 $	.8) )	% 	%r7   socksslserver_hostnameorigin
extensionssubprotocolscompressiondeflaterB   rD   proxyT	proxy_sslproxy_server_hostnameopen_timeoutr%   r&   r'   max_sizer(   loggercreate_connectionc          .     t    V ^8  d   QhRRRRRRRRR	R
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRR R!R"R#R$R%R&/# )'r*   uristrrh   zsocket.socket | Noneri   ssl_module.SSLContext | Nonerj   rE   rk   zOrigin | Nonerl   z'Sequence[ClientExtensionFactory] | Nonerm   zSequence[Subprotocol] | Nonern   rB   rC   rD   rp   zstr | Literal[True] | Nonerq   rr   rs   r.   r%   r&   r'   rt   r/   r(   ru   zLoggerLike | Nonerv   ztype[ClientConnection] | Nonekwargsr   r0   r#   r2   )r3   s   "r4   r5   r5      s	    F F	F 	F
 
&F  F F 8F /F F +F "F &F  ,!F" &#F& 'F(  )F* +F,  -F0 91F2 :3F6 7F: 5;F< =F> ?Fr7   c          	     L   Vf4   RV9   d-   VP                  R4      p\        P                  ! R\        4       \	        V 4      pVP
                  '       g   Ve   \        R4      hVP                  RR4      pVP                  RR4      pV'       d'   Vf   Vf   \        R4      hVe   Ve   \        R	4      hVe   \        V4       VR
8X  d   \        V4      pMVe   \        RV 24      hV'       d   Rp
Ve   Rp
V
RJ d   \        V4      p
\        V4      pVf   \        p VEfp   V'       dk   \        P                  ! \        P                  \        P                  4      pVP                  VP!                  4       4       Vf   Q hVP#                  V4       MV
e   \%        V
4      pVP&                  R,          R8X  d!   \)        VVVVP                  RR4      R7      pMVP&                  R,          R8X  d6   VP&                  R8w  d   Ve   \        R4      h\+        VVV3RV	RVRV/VB pMX\-        R4      hVP/                  RVP!                  4       4       \        P0                  ! VP2                  VP4                  33/ VB pVP                  R4       V'       g0   VP7                  \        P8                  \        P:                  R4       VP
                  '       d   Vf   \<        P>                  ! 4       pVf   VP2                  pVP                  VP!                  4       4       Vf   VPA                  WR7      pM'\C        WVR7      p\E        \        P                  V4      pVP                  R4       \G        VVVVVVR7      pV! VVVVVVR7      p TPM                  TT	TP!                  4       4       TPU                  4        T#   \H         d    Te   TPK                  4        h i ; i  \H         d-    TPO                  4        TPP                  PS                  4        h i ; i)a  
Connect to the WebSocket server at ``uri``.

This function returns a :class:`ClientConnection` instance, which you can
use to send and receive messages.

:func:`connect` may be used as a context manager::

    from websockets.sync.client import connect

    with connect(...) as websocket:
        ...

The connection is closed automatically when exiting the context.

Args:
    uri: URI of the WebSocket server.
    sock: Preexisting TCP socket. ``sock`` overrides the host and port
        from ``uri``. You may call :func:`socket.create_connection` to
        create a suitable TCP socket.
    ssl: Configuration for enabling TLS on the connection.
    server_hostname: Host name for the TLS handshake. ``server_hostname``
        overrides the host name from ``uri``.
    origin: Value of the ``Origin`` header, for servers that require it.
    extensions: List of supported extensions, in order in which they
        should be negotiated and run.
    subprotocols: List of supported subprotocols, in order of decreasing
        preference.
    compression: The "permessage-deflate" extension is enabled by default.
        Set ``compression`` to :obj:`None` to disable it. See the
        :doc:`compression guide <../../topics/compression>` for details.
    additional_headers (HeadersLike | None): Arbitrary HTTP headers to add
        to the handshake request.
    user_agent_header: Value of  the ``User-Agent`` request header.
        It defaults to ``"Python/x.y.z websockets/X.Y"``.
        Setting it to :obj:`None` removes the header.
    proxy: If a proxy is configured, it is used by default. Set ``proxy``
        to :obj:`None` to disable the proxy or to the address of a proxy
        to override the system configuration. See the :doc:`proxy docs
        <../../topics/proxies>` for details.
    proxy_ssl: Configuration for enabling TLS on the proxy connection.
    proxy_server_hostname: Host name for the TLS handshake with the proxy.
        ``proxy_server_hostname`` overrides the host name from ``proxy``.
    open_timeout: Timeout for opening the connection in seconds.
        :obj:`None` disables the timeout.
    ping_interval: Interval between keepalive pings in seconds.
        :obj:`None` disables keepalive.
    ping_timeout: Timeout for keepalive pings in seconds.
        :obj:`None` disables timeouts.
    close_timeout: Timeout for closing the connection in seconds.
        :obj:`None` disables the timeout.
    max_size: Maximum size of incoming messages in bytes.
        :obj:`None` disables the limit. You may pass a ``(max_message_size,
        max_fragment_size)`` tuple to set different limits for messages and
        fragments when you expect long messages sent in short fragments.
    max_queue: High-water mark of the buffer where frames are received.
        It defaults to 16 frames. The low-water mark defaults to ``max_queue
        // 4``. You may pass a ``(high, low)`` tuple to set the high-water
        and low-water marks. If you want to disable flow control entirely,
        you may set it to ``None``, although that's a bad idea.
    logger: Logger for this client.
        It defaults to ``logging.getLogger("websockets.client")``.
        See the :doc:`logging guide <../../topics/logging>` for details.
    create_connection: Factory for the :class:`ClientConnection` managing
        the connection. Set it to a wrapper or a subclass to customize
        connection handling.

Any other keyword arguments are passed to :func:`~socket.create_connection`.

Raises:
    InvalidURI: If ``uri`` isn't a valid WebSocket URI.
    OSError: If the TCP connection fails.
    InvalidHandshake: If the opening handshake fails.
    TimeoutError: If the opening handshake times out.

Nssl_contextzssl_context was renamed to sslz-ssl argument is incompatible with a ws:// URIunixFpathzmissing path argumentz(path and sock arguments are incompatiblero   zunsupported compression: T:N   Nsockssource_address)
local_addr:N   Nhttphttpsz8proxy_ssl argument is incompatible with an http:// proxyrD   ri   rj   zunsupported proxyrF   rj   )rk   rl   rm   rt   ru   r9   )+popwarningswarnDeprecationWarningr    secure
ValueErrorr   r   r   r"   r#   r+   AF_UNIXSOCK_STREAM
settimeoutrF   rJ   r   schemeconnect_socks_proxyconnect_http_proxyAssertionErrorrN   rv   hostport
setsockoptIPPROTO_TCPTCP_NODELAY
ssl_modulecreate_default_contextwrap_socketSSLSSLSocketr	   r
   	ExceptioncloserS   close_socketrecv_events_threadjoinstart_keepalive)rx   rh   ri   rj   rk   rl   rm   rn   rB   rD   rp   rq   rr   rs   r%   r&   r'   rt   r(   ru   rv   r{   ws_urir~   r   deadlineproxy_parsedsock_2r-   
connections   &$$$$$$$$$$$$$$$$$$$$,        r4   rJ   rJ      s   ` {}.jj',	

 s^F===S_HII FE*Dzz&$/D<DL455$"2GHHl+i5jA
		 4[MBCC}&!
 %H ,\ <}}V^^V5G5GH 0 0 23'''T""*51&&r*g5.$  $*::.>#ED "((,6#**g5):O(V  .$  +<	
 & )> !D ))<==!!)X-=-=-?@//[[&++. OOD! OOF..0B0BDI ==={ 779&"(++OOH,,./ tM%dQFMM62OOD! "!%
 ''%'

		
  #  JJL  !%%**,s-   !O .E.O A O B6O !O, !O),7P#c               (    V ^8  d   QhRRRRRRRR/# )r*   r   rE   rx   r{   r   r0   r#   r2   )r3   s   "r4   r5   r5     s0     < <
<	< < 	<r7   c           	         Vf,   VP                  R4      f   VP                  R4      f   RpMRp\        R	RVRRRV /VB # )
a  
Connect to a WebSocket server listening on a Unix socket.

This function accepts the same keyword arguments as :func:`connect`.

It's only available on Unix.

It's mainly useful for debugging servers listening on Unix sockets.

Args:
    path: File system path to the Unix socket.
    uri: URI of the WebSocket server. ``uri`` defaults to
        ``ws://localhost/`` or, when a ``ssl`` is provided, to
        ``wss://localhost/``.

ri   r}   zws://localhost/zwss://localhost/rx   r~   Tr   r2   )getrJ   )r   rx   r{   s   &&,r4   unix_connectr     sM    * {::e$M)B)J#C$C;s;;D;F;;r7   )	ProxyType)r   socks5hsocks5socks4asocks4Fc          
     ,    V ^8  d   QhRRRRRRRRR	R
/# r*   rp   r   r   r   r   r"   r{   r   r0   r,   r2   )r3   s   "r4   r5   r5     sA     J JJJ J 	J
 
Jr7   c           	        \        \        V P                  ,          V P                  V P                  V P
                  V P                  \        V P                  ,          4      pVP                  RVP                  4       4        VP                  ! VP                  VP                  3/ VB #   \        \        \        P                  3 d    h \         d   p\        R4      ThRp?ii ; i)z0Connect via a SOCKS proxy and return the socket.rF   z failed to connect to SOCKS proxyN)
SocksProxySOCKS_PROXY_TYPESr   r   r   usernamepasswordSOCKS_PROXY_RDNSrN   rF   rJ   OSErrorrQ   r+   r   r   )rp   r   r   r{   socks_proxyexcs   &&&,  r4   r   r     s     !ell+JJJJNNNNU\\*
 	)X%5%5%78	J&&v{{FKKJ6JJv~~6 	 	J?@cI	Js   'B, ,)C(C(C##C(c          
     ,    V ^8  d   QhRRRRRRRRR	R
/# r   r2   )r3   s   "r4   r5   r5     sA     T TTT T 	T
 
Tr7   c                    \        R 4      h)z6connecting through a SOCKS proxy requires python-socks)ImportError)rp   r   r   r{   s   &&&,r4   r   r     s     RSSr7   c               $    V ^8  d   QhRRRRRR/# )r*   rh   r,   r   r"   r0   r   r2   )r3   s   "r4   r5   r5     s!        h r7   c                   \        4       p\        P                  ! VP                  VP                  VP
                  R R7      p  V P                  VP                  4       4       V P                  R4      pV'       d   VP                  V4       MVP                  4        \        V4       Kh    \         ds   p\        TP                  \        4      '       g   Q hTP                  p^TP                  u;8:  d   R8  d   M MTu Rp?T P                  R4       # \!        T4      hRp?i\"        P                   d    \%        R4      h\&         d   p\)        R4      ThRp?ii ; i  T P                  R4       i ; i)T)rp   i   i,  Nz(timed out while connecting to HTTP proxyz0did not receive a valid HTTP response from proxy)r   r   parse	read_line
read_exactread_to_eofr   rF   recv	feed_datafeed_eofnextStopIterationrY   valuestatus_coder   r+   rQ   r   r   )rh   r   readerparserdatar   rX   s   &&     r4   read_connect_responser     s(   ^F^^	FOOH,,./99T?D  &!L /#))X....99(&&,,O 	 %X..>> GEFF !>
	
 	sU   8B, =/B, ,E"7AD$E"E% D$$E";E"E"EE""E% %E8c               8    V ^8  d   QhRRRRRRRRR	R
RRRRRR/# )r*   rp   r   r   r   r   r"   rD   rE   ri   rz   rj   r{   r   r0   r,   r2   )r3   s   "r4   r5   r5     sX     # ### #
 "# 
&#  # # #r7   c               &   VP                  R VP                  4       4       \        P                  ! V P                  V P
                  33/ VB pV P                  R8X  dl   Vf   \        P                  ! 4       pVf   V P                  pVP                  VP                  4       4       VP                  WuR7      pVP                  R4       VP                  \        WV4      4        \        Wr4       V#   \         d    TP                  4        h i ; i)rF   r   Nr   )rN   rF   r+   rv   r   r   r   r   r   r   r   sendallr   r   r   r   )rp   r   r   rD   ri   rj   r{   rh   s   &&&$$$, r4   r   r     s     i!1!1!34##UZZ$<GGD ||w;335C"#jjO((*+tE 	LL(8IJKd-
 K	  

s   &C3 3DTF.)boundc                  j    ] tR tRtRtRtRR R lltR R ltR	 R
 ltR R lt	R R lt
R R ltRtR# )r   i,  zf
Socket-like object providing TLS-in-TLS.

Only methods that are used by websockets are implemented.

i   Nc               (    V ^8  d   QhRRRRRRRR/# )	r*   rh   r,   r}   zssl_module.SSLContextrj   rE   r0   r1   r2   )r3   s   "r4   r5   SSLSSLSocket.__annotate__6  s2     2 22 +2 $	2
 
2r7   c                	   \         P                  ! 4       V n        \         P                  ! 4       V n        Wn        VP                  V P                  V P                  VR 7      V n        V P                  V P                  P                  4       R# )r   N)	r   	MemoryBIOincomingoutgoing
ssl_socketwrap_bio
ssl_objectrun_iodo_handshake)r>   rh   r}   rj   s   &&&&r4   r=   SSLSSLSocket.__init__6  si     #,,.",,.%..MMMM+ / 

 	DOO001r7   c               $    V ^8  d   QhRRRRRR/# )r*   funczCallable[..., T]argsr   r0   r   r2   )r3   s   "r4   r5   r   F  s"      + C A r7   c                	    RpRp V! V!  pV P                  P	                  4       pV'       d   V P
                  P                  V4       V'       df   V P
                  P                  V P                  4      pV'       d   V P                  P                  V4       MV P                  P                  4        K  V'       d   K  X#   \         P                   d    R p L\         P                   d    R p Li ; i)TF)r   SSLWantReadErrorSSLWantWriteErrorr   readr   r   r   recv_bufsizer   write	write_eof)r>   r   r   	want_read
want_writeresultr   s   &&*    r4   r   SSLSSLSocket.run_ioF  s    IJ"t ==%%'D''- ++D,=,=>MM''-MM++-M- .. ! 	// "!
"s   C C5C5/C54C5c                    V ^8  d   QhRRRR/# )r*   buflenintr0   bytesr2   )r3   s   "r4   r5   r   d  s      3 5 r7   c                	     V P                  V P                  P                  V4      #   \        P                   d     R # i ; i)r7   )r   r   r   r   SSLEOFError)r>   r   s   &&r4   r   SSLSSLSocket.recvd  s:    	;;t33V<<%% 		s   %( A Ac                    V ^8  d   QhRRRR/# )r*   r   r   r0   r   r2   )r3   s   "r4   r5   r   j  s     8 8 8s 8r7   c                	N    V P                  V P                  P                  V4      # N)r   r   r   )r>   r   s   &&r4   sendSSLSSLSocket.sendj  s    {{4??00$77r7   c                    V ^8  d   QhRRRR/# )r*   r   r   r0   r1   r2   )r3   s   "r4   r5   r   m  s     6 6I 6$ 6r7   c           
     	,   ^ p\        V4      ;_uu_ 4       q3P                  R4      ;_uu_ 4       p\        V4      pW%8  d   W P                  WBR 4      ,          pK!   RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)r   BN)
memoryviewr	   lenr   )r>   r   countview	byte_viewamounts   &&    r4   r   SSLSSLSocket.sendallm  sc    yy~~^F.9V#455 ! (6~~s"   B-A/	B/A?:BB	c                    V ^8  d   QhRRRR/# )r*   namery   r0   r   r2   )r3   s   "r4   r5   r   x  s     . . . .r7   c                	.    \        V P                  V4      # r   )getattrr   )r>   r	  s   &&r4   __getattr__SSLSSLSocket.__getattr__x  s    t--r7   )r   r   r   r   r   )ra   rb   rc   rd   re   r   r=   r   r   r   r   r  rf   r2   r7   r4   r   r   ,  s1     L2 <86. .r7   r   )rJ   r   r#   i   )NN)H
__future__r   r+   ri   r   r:   r   collections.abcr   typingr   r   r   r   r	   clientr
   datastructuresr   
exceptionsr   r   r   extensions.baser   extensions.permessage_deflater   rL   r   http11r   r   r-   r   r   rp   r   r   r   r   streamsr   r   r   r   r   rx   r   r    r   r!   utilsr"   __all__r#   rJ   r   python_socksr   python_socks.syncr   SOCKS5SOCKS4r   r   r   r   r   r   r   r   r   r2   r7   r4   <module>r     s%   "     $ 8 8 # ( L L 4 L + ) ( J J " ? ? ) "  :b%z b%JF "&	F
 )-F #'F !F ;?F 26F (F .2F %/F )-F  /3!F" )-#F& "$'F( #%)F* "$+F, #%-F0 <A1F2 =?3F6 !%7F: 8<;FR<<4J&5 	9##)""9##)""	 	4%4%	J4D#
 %)# )-# #'#L CLCxQ'(M. M.  TTTs   E& &E65E6