§
    ¨öÉg�  ã                   óü   — d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 ddl
mZmZmZmZmZmZmZ ddlmZ ddlmZmZmZmZ dd	lmZ  G d
„ de¦  «        Z G d„ de¦  «        Zej        Zej        Z G d„ d¦  «        ZdS )zU
wsproto/connection
~~~~~~~~~~~~~~~~~~

An implementation of a WebSocket connection.
é    )Údeque)ÚEnum)ÚDequeÚ	GeneratorÚListÚOptionalé   )ÚBytesMessageÚCloseConnectionÚEventÚMessageÚPingÚPongÚTextMessage)Ú	Extension)ÚCloseReasonÚFrameProtocolÚOpcodeÚParseFailed)ÚLocalProtocolErrorc                   ó*   — e Zd ZdZdZdZdZdZdZdZ	dS )	ÚConnectionStatez1
    RFC 6455, Section 4 - Opening Handshake
    r   r	   é   é   é   é   N)
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
CONNECTINGÚOPENÚREMOTE_CLOSINGÚLOCAL_CLOSINGÚCLOSEDÚ	REJECTING© ó    ú^/var/www/html/nodeJS/PythonScripts/venv3.11/lib/python3.11/site-packages/wsproto/connection.pyr   r      s8   € € € € € ðð ð
 €Jà€Dà€Nà€Mà€Fà€I€I€Ir(   r   c                   ó   — e Zd ZdZdZdZdS )ÚConnectionTypez#An enumeration of connection types.r	   r   N)r   r   r   r    ÚCLIENTÚSERVERr'   r(   r)   r+   r+   -   s"   € € € € € Ø-Ð-ð €Fð €F€F€Fr(   r+   c            	       ó®   — e Zd ZdZ	 	 ddedeee                  deddfd„Z	e
defd	„¦   «         Zd
edefd„Zdee         ddfd„Zdeeddf         fd„ZdS )Ú
Connectionaä  
    A low-level WebSocket connection object.

    This wraps two other protocol objects, an HTTP/1.1 protocol object used
    to do the initial HTTP upgrade handshake and a WebSocket frame protocol
    object used to exchange messages and other control frames.

    :param conn_type: Whether this object is on the client- or server-side of
        a connection. To initialise as a client pass ``CLIENT`` otherwise
        pass ``SERVER``.
    :type conn_type: ``ConnectionType``
    Nr(   Úconnection_typeÚ
extensionsÚtrailing_dataÚreturnc                 óÖ   — |t           j        u | _        t          ¦   «         | _        t          | j        |pg ¦  «        | _        t          j        | _	        |  
                    |¦  «         d S ©N)r+   r,   Úclientr   Ú_eventsr   Ú_protor   r"   Ú_stateÚreceive_data)Úselfr0   r1   r2   s       r)   Ú__init__zConnection.__init__I   sZ   € ð &­Ô)>Ð>ˆŒÝ%*¡W¤WˆŒÝ# D¤K°Ð1A¸rÑBÔBˆŒÝ%Ô*ˆŒØ×Ò˜-Ñ(Ô(Ð(Ð(Ð(r(   c                 ó   — | j         S r5   )r9   )r;   s    r)   ÚstatezConnection.stateU   s
   € àŒ{Ðr(   Úeventc                 óF  — d}t          |t          ¦  «        r?| j        t          j        k    r*|| j                             |j        |j        ¦  «        z  }�nJt          |t          ¦  «        r8| j        t          j        k    r#|| j         
                    |j        ¦  «        z  }nýt          |t          ¦  «        r8| j        t          j        k    r#|| j                             |j        ¦  «        z  }n°t          |t          ¦  «        r€| j        t          j        t          j        hv ra|| j                             |j        |j        ¦  «        z  }| j        t          j        k    rt          j        | _        n-t          j        | _        nt-          d|› d| j        › d�¦  «        ‚|S )Nr(   zEvent z cannot be sent in state ú.)Ú
isinstancer   r>   r   r"   r8   Ú	send_dataÚdataÚmessage_finishedr   ÚpingÚpayloadr   Úpongr   r#   ÚcloseÚcodeÚreasonr%   r9   r$   r   )r;   r?   rD   s      r)   ÚsendzConnection.sendY   sv  € ØˆÝ�e�WÑ%Ô%ð 	¨$¬*½Ô8LÒ*LÐ*LØ�D”K×)Ò)¨%¬*°eÔ6LÑMÔMÑMˆD‰DÝ˜�tÑ$Ô$ð 	¨¬µÔ7KÒ)KÐ)KØ�D”K×$Ò$ U¤]Ñ3Ô3Ñ3ˆDˆDÝ˜�tÑ$Ô$ð 	¨¬µÔ7KÒ)KÐ)KØ�D”K×$Ò$ U¤]Ñ3Ô3Ñ3ˆDˆDÝ˜�Ñ/Ô/ð 	°D´JÝÔ ÝÔ*ðC
ð 5
ð 5
ð �D”K×%Ò% e¤j°%´,Ñ?Ô?Ñ?ˆDØŒz�_Ô;Ò;Ð;Ý-Ô4�”�å-Ô;�”�å$ØF˜ÐFÐF¸¼ÐFÐFÐFñô ð ð ˆr(   rD   c                 óN  — |€E| j                              t          t          j        ¬¦  «        ¦  «         t
          j        | _        dS | j        t
          j	        t
          j
        fv r| j                             |¦  «         dS | j        t
          j        u rt          d¦  «        ‚dS )aO  
        Pass some received data to the connection for handling.

        A list of events that the remote peer triggered by sending this data can
        be retrieved with :meth:`~wsproto.connection.Connection.events`.

        :param data: The data received from the remote peer on the network.
        :type data: ``bytes``
        N)rJ   zConnection already closed.)r7   Úappendr   r   ÚABNORMAL_CLOSUREr   r%   r9   r>   r"   r$   r8   Úreceive_bytesr   )r;   rD   s     r)   r:   zConnection.receive_datap   s–   € ð ˆ<ð
 ŒL×Ò¥µ[Ô5QÐ RÑ RÔ RÑSÔSÐSÝ)Ô0ˆDŒKØˆFàŒ:�/Ô.µÔ0MÐNÐNÐNØŒK×%Ò% dÑ+Ô+Ð+Ð+Ð+ØŒZ�?Ô1Ð1Ð1Ý$Ð%AÑBÔBÐBàˆDr(   c              #   óò  K  — | j         r"| j                              ¦   «         V — | j         °"	 | j                             ¦   «         D �]ò}|j        t
          j        u rK|j        r|j        sJ ‚t          |j
        t          t          f¦  «        sJ ‚t          |j
        ¬¦  «        V — Œa|j        t
          j        u rK|j        r|j        sJ ‚t          |j
        t          t          f¦  «        sJ ‚t          |j
        ¬¦  «        V — Œ¿|j        t
          j        u rqt          |j
        t"          ¦  «        sJ ‚|j
        \  }}| j        t&          j        u rt&          j        | _        nt&          j        | _        t1          ||¬¦  «        V — �ŒC|j        t
          j        u rAt          |j
        t4          ¦  «        sJ ‚t7          |j
        |j        |j        ¬¦  «        V — �Œ—|j        t
          j        u rHt          |j
        t          t          f¦  «        sJ ‚t;          |j
        |j        |j        ¬¦  «        V — �Œò�ŒôdS # t<          $ r0}t1          |j        t5          |¦  «        ¬¦  «        V — Y d}~dS d}~ww xY w)zÅ
        Return a generator that provides any events that have been generated
        by protocol activity.

        :returns: generator of :class:`Event <wsproto.events.Event>` subclasses
        )rG   )rJ   rK   )rD   Úframe_finishedrE   N) r7   Úpopleftr8   Úreceived_framesÚopcoder   ÚPINGrR   rE   rB   rG   ÚbytesÚ	bytearrayr   ÚPONGr   ÚCLOSEÚtupler>   r   r$   r%   r9   r#   r   ÚTEXTÚstrr   ÚBINARYr
   r   rJ   )r;   ÚframerJ   rK   Úexcs        r)   ÚeventszConnection.events‹   s¹  è è € ð Œlð 	)Ø”,×&Ò&Ñ(Ô(Ð(Ð(Ð(ð Œlð 	)ð(	BØœ×4Ò4Ñ6Ô6ð %ñ %�Ø”<¥6¤;Ð.Ð.Ø Ô/ÐJ°EÔ4JÐJÐJÐJÝ% e¤mµe½YÐ5GÑHÔHÐHÐHÐHÝ u¤}Ð5Ñ5Ô5Ð5Ð5Ð5Ð5à”\¥V¤[Ð0Ð0Ø Ô/ÐJ°EÔ4JÐJÐJÐJÝ% e¤mµe½YÐ5GÑHÔHÐHÐHÐHÝ u¤}Ð5Ñ5Ô5Ð5Ð5Ð5Ð5à”\¥V¤\Ð1Ð1Ý% e¤mµUÑ;Ô;Ð;Ð;Ð;Ø#(¤=‘L�D˜&Ø”z¥_Ô%BÐBÐBÝ&5Ô&<˜œ˜å&5Ô&D˜œÝ)¨t¸FÐCÑCÔCÐCÐCÐCÑCà”\¥V¤[Ð0Ð0Ý% e¤mµSÑ9Ô9Ð9Ð9Ð9Ý%Ø"œ]Ø',Ô';Ø).Ô)?ðñ ô ð ð ð ñ ð ”\¥V¤]Ð2Ð2Ý% e¤mµe½YÐ5GÑHÔHÐHÐHÐHÝ&Ø"œ]Ø',Ô';Ø).Ô)?ðñ ô ð ð ð ñ ñ ðK%ð %øõL ð 	Bð 	Bð 	BÝ! s¤x½¸C¹¼ÐAÑAÔAÐAÐAÐAÐAÐAÐAÐAÐAÐAøøøøð	Bøøøs   ­HH< È<
I6É%I1É1I6)Nr(   )r   r   r   r    r+   r   r   r   rW   r<   Úpropertyr   r>   r   rL   r:   r   ra   r'   r(   r)   r/   r/   ;   s  € € € € € ðð ð  15Ø"ð	
)ð 
)à'ð
)ð ˜T )œ_Ô-ð
)ð ð	
)ð
 
ð
)ð 
)ð 
)ð 
)ð ð�ð ð ð ñ „Xðð˜%ð  Eð ð ð ð ð. ¨%¤ð °Tð ð ð ð ð62B˜	 %¨¨tÐ"3Ô4ð 2Bð 2Bð 2Bð 2Bð 2Bð 2Br(   r/   N) r    Úcollectionsr   Úenumr   Útypingr   r   r   r   ra   r
   r   r   r   r   r   r   r1   r   Úframe_protocolr   r   r   r   Ú	utilitiesr   r   r+   r,   r-   r/   r'   r(   r)   ú<module>rh      s©  ððð ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð "Ð !Ð !Ð !Ð !Ð !Ø KÐ KÐ KÐ KÐ KÐ KÐ KÐ KÐ KÐ KÐ KÐ KØ )Ð )Ð )Ð )Ð )Ð )ðð ð ð ð �dñ ô ð ð&ð ð ð ð �Tñ ô ð ð 
Ô	€Ø	Ô	€ðBBð BBð BBð BBð BBñ BBô BBð BBð BBð BBr(   