§
    ¿Ái™  ã                  óŒ   — d Z ddlmZ ddlmZ ddlmZmZmZ ddl	m
Z
 erddlmZ ddlmZ dd	lmZ d
Z G d„ d¦  «        ZdZdS )z.
wsproto
~~~~~~~

A WebSocket implementation.
é    )Úannotations)ÚTYPE_CHECKINGé   )Ú
ConnectionÚConnectionStateÚConnectionType)ÚH11Handshake)Ú	Generator)ÚEvent)ÚHeadersz1.3.2c                  óR   — e Zd ZdZdd„Zedd„¦   «         Zdd„Zdd„Zdd„Z	dd„Z
dS )ÚWSConnectionzN
    Represents the local end of a WebSocket connection to a remote peer.
    Úconnection_typer   ÚreturnÚNonec                ób   — |t           j        u | _        t          |¦  «        | _        d| _        dS )z­
        Constructor

        :param wsproto.connection.ConnectionType connection_type: Controls
            whether the library behaves as a client or as a server.
        N)r   ÚCLIENTÚclientr	   Ú	handshakeÚ
connection)Úselfr   s     ú;/usr/local/lib/python3.11/dist-packages/wsproto/__init__.pyÚ__init__zWSConnection.__init__   s-   € ð &­Ô)>Ð>ˆŒÝ% oÑ6Ô6ˆŒØ-1ˆŒˆˆó    r   c                ó@   — | j         €| j        j        S | j         j        S )z_
        :returns: Connection state
        :rtype: wsproto.connection.ConnectionState
        )r   r   Ústate©r   s    r   r   zWSConnection.state'   s"   € ð Œ?Ð"Ø”>Ô'Ð'ØŒÔ$Ð$r   Úheadersr   Úpathúbytes | strc                ó<   — | j                              ||¦  «         d S )N)r   Úinitiate_upgrade_connection)r   r   r   s      r   r"   z(WSConnection.initiate_upgrade_connection1   s"   € ð 	Œ×2Ò2°7¸DÑAÔAÐAÐAÐAr   Úeventr   Úbytesc                ó°   — d}| j         €/|| j                             |¦  «        z  }| j        j         | _         n|| j                              |¦  «        z  }|S )a‹  
        Generate network data for the specified event.

        When you want to communicate with a WebSocket peer, you should construct
        an event and pass it to this method. This method will return the bytes
        that you should send to the peer.

        :param wsproto.events.Event event: The event to generate data for
        :returns bytes: The data to send to the peer
        r   )r   r   Úsend)r   r#   Údatas      r   r&   zWSConnection.send6   sX   € ð ˆØŒ?Ð"ØD”N×'Ò'¨Ñ.Ô.Ñ.ˆDØ"œnÔ7ˆDŒOˆOàD”O×(Ò(¨Ñ/Ô/Ñ/ˆDØˆr   r'   úbytes | Nonec                ó¢   — | j         €-| j                             |¦  «         | j        j         | _         dS | j                              |¦  «         dS )zý
        Feed network data into the connection instance.

        After calling this method, you should call :meth:`events` to see if the
        received data triggered any new events.

        :param bytes data: Data received from remote peer
        N)r   r   Úreceive_data)r   r'   s     r   r*   zWSConnection.receive_dataI   sN   € ð Œ?Ð"ØŒN×'Ò'¨Ñ-Ô-Ð-Ø"œnÔ7ˆDŒOˆOˆOàŒO×(Ò(¨Ñ.Ô.Ð.Ð.Ð.r   úGenerator[Event, None, None]c              #  ó˜   K  — | j                              ¦   «         E d{V —† | j        !| j                             ¦   «         E d{V —† dS dS )z”
        A generator that yields pending events.

        Each event is an instance of a subclass of
        :class:`wsproto.events.Event`.
        N)r   Úeventsr   r   s    r   r-   zWSConnection.eventsX   sj   è è € ð ”>×(Ò(Ñ*Ô*Ð*Ð*Ð*Ð*Ð*Ð*Ð*ØŒ?Ð&Ø”×-Ò-Ñ/Ô/Ð/Ð/Ð/Ð/Ð/Ð/Ð/Ð/Ð/ð 'Ð&r   N)r   r   r   r   )r   r   )r   r   r   r    r   r   )r#   r   r   r$   )r'   r(   r   r   )r   r+   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r"   r&   r*   r-   © r   r   r   r      s¦   € € € € € ðð ð	2ð 	2ð 	2ð 	2ð ð%ð %ð %ñ „Xð%ðBð Bð Bð Bð
ð ð ð ð&/ð /ð /ð /ð	0ð 	0ð 	0ð 	0ð 	0ð 	0r   r   )r   r   N)r1   Ú
__future__r   Útypingr   r   r   r   r   r   r	   Úcollections.abcr
   r-   r   r   Ú__version__r   Ú__all__r3   r   r   ú<module>r9      sä   ððð ð #Ð "Ð "Ð "Ð "Ð "à  Ð  Ð  Ð  Ð  Ð  à CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CÐ CØ #Ð #Ð #Ð #Ð #Ð #àð  Ø)Ð)Ð)Ð)Ð)Ð)àÐÐÐÐÐØÐÐÐÐÐà€ðJ0ð J0ð J0ð J0ð J0ñ J0ô J0ð J0ðZ -€€€r   