
    2h                         % S r SSKrSSKrSSKJr  SSKJrJr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JrJrJrJrJrJrJr  S	SKJrJr  Sr\\   \S'   Sr  " S S5      r!g)z%WebSocket protocol versions 13 and 8.    N)partial)AnyFinalOptionalUnion   )BaseProtocol)ClientConnectionResetError)ZLibBackendZLibCompressor   )MASK_LENMSG_SIZEPACK_CLOSE_CODE	PACK_LEN1	PACK_LEN2	PACK_LEN3PACK_RANDBITSwebsocket_mask)WS_DEFLATE_TRAILING	WSMsgType   DEFAULT_LIMITi   c                       \ rS rSrSrS\\R                  " 5       SSS.S\S\	R                  S\S	\S
\R                  S\S\SS4S jjr SS\S\S\\   SS4S jjrS\S\4S jrSS\S\\\4   SS4S jjrSrg)WebSocketWriter#   a  WebSocket writer.

The writer is responsible for sending messages to the client. It is
created by the protocol when a connection is established. The writer
should avoid implementing any application logic and should only be
concerned with the low-level details of the WebSocket protocol.
Fr   )use_masklimitrandomcompress
notakeoverprotocol	transportr   r   r   r    r!   returnNc                    Xl         X l        X0l        [        UR                  S5      U l        X`l        Xpl        SU l        X@l	        SU l
        SU l        g)zInitialize a WebSocket writer.    Fr   N)r"   r#   r   r   getrandbitsget_random_bitsr    r!   _closing_limit_output_size_compressobj)selfr"   r#   r   r   r   r    r!   s           Q/var/www/auris/envauris/lib/python3.13/site-packages/aiohttp/_websocket/writer.py__init__WebSocketWriter.__init__,   sN     !" &v'9'92> $!%    messageopcodec                   #    U R                   (       a#  U[        R                  -  (       d  [        S5      eSnU(       d  U R                  (       a  US:  a  SnU(       a  U R                  U5      nO=U R                  (       d   U R                  U R                  5      U l        U R                  nUR	                  U5      I Sh  vN UR                  U R                  (       a  [        R                  O[        R                  5      -   R                  [        5      n[        U5      nU R                  nU(       a  SOSnSU-  U-  n	US:  a  [!        XU-  5      n
SnO+US	:  a  [#        U	SU-  U5      n
S
nO[%        U	SU-  U5      n
SnU R&                  R)                  5       (       a  [        S5      eU(       ai  [+        U R-                  5       5      n[/        U5      n[1        X5        U R&                  R3                  X-   U-   5        U =R4                  [6        -  sl        O^U[8        :  a7  U R&                  R3                  U
5        U R&                  R3                  U5        OU R&                  R3                  X-   5        U =R4                  X-   -  sl        U R4                  U R:                  :  aF  SU l        U R<                  R>                  (       a#  U R<                  RA                  5       I Sh  vN   ggg GN5 N
7f)z<Send a frame over the websocket with message as its payload.z!Cannot write to closing transportr      @   N   ~   r   r         
   )!r)   r   CLOSEr
   r    _make_compress_objr,   flushr!   r   Z_FULL_FLUSHZ_SYNC_FLUSHremovesuffixr   lenr   r   r   r   r#   
is_closingr   r(   	bytearrayr   writer+   r   r   r*   r"   _paused_drain_helper)r-   r2   r3   r    rsvcompressobj
msg_lengthr   mask_bit
first_byteheader
header_lenmasks                r.   
send_frameWebSocketWriter.send_frameC   sq     ==&9??":,-PQQ
  6A: C"55h?(((,(?(?(ND%"// "**733##  ,,$11 l./  \
==#4 CZ&(
z+@AFJ%z3>:FFJz3>:FFJ>>$$&&,-PQQ  !5!5!78D(G4)NN  !89)("NN  (NN  )NN  !12Z44 t{{* !D}}$$mm11333 % +} 4B 4s%   CK=K8H,K=0K;1K=;K=c                 >    [        [        R                  U* [        S9$ )N)levelwbitsmax_sync_chunk_size)r   r   Z_BEST_SPEEDWEBSOCKET_MAX_SYNC_CHUNK_SIZE)r-   r    s     r.   r=   "WebSocketWriter._make_compress_obj   s     **) =
 	
r1   codec                    #    [        U[        5      (       a  UR                  S5      n U R                  [	        U5      U-   [
        R                  S9I Sh  vN   SU l        g N! SU l        f = f7f)z<Close the websocket, sending the specified code and message.zutf-8)r3   NT)
isinstancestrencoderP   r   r   r<   r)   )r-   rY   r2   s      r.   closeWebSocketWriter.close   sk     gs##nnW-G	!//%/	 "    !DM	 !DMs.   'A2-A& A$A& A2$A& &	A//A2)
r)   r,   r*   r+   r    r(   r!   r"   r#   r   )N)i  r1   )__name__
__module____qualname____firstlineno____doc__r   r   Randomr	   asyncio	Transportboolintr/   bytesr   rP   r   r=   r   r\   r^   __static_attributes__ r1   r.   r   r   #   s     " & && $$&
 & & & & & 
&0 FJ]4]4&)]45=c]]4	]4~
3 
> 
	! 	!U5#:5F 	!QU 	! 	!r1   r   )"rd   rf   r   	functoolsr   typingr   r   r   r   base_protocolr	   client_exceptionsr
   compression_utilsr   r   helpersr   r   r   r   r   r   r   r   modelsr   r   r   ri   __annotations__rW   r   rl   r1   r.   <module>ru      sV    +    . . ( : ;	 	 	 3!uSz ! !) O! O!r1   