Ë
    aQbj™  ã                  ó„   — 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y)z.
wsproto
~~~~~~~

A WebSocket implementation.
é    )Úannotations)ÚTYPE_CHECKINGé   )Ú
ConnectionÚConnectionStateÚConnectionType)ÚH11Handshake)Ú	Generator)ÚEvent)ÚHeadersz1.3.2c                  óV   — 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
y)ÚWSConnectionzN
    Represents the local end of a WebSocket connection to a remote peer.
    c                ó`   — |t         j                  u | _        t        |«      | _        d| _        y)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)ÚselfÚconnection_types     úC/var/www/html/venv/lib/python3.12/site-packages/wsproto/__init__.pyÚ__init__zWSConnection.__init__   s)   € ð &¬×)>Ñ)>Ð>ˆŒÜ% oÓ6ˆŒØ-1ˆ�ó    c                ór   — | 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   c                ó<   — | j                   j                  ||«       y )N)r   Úinitiate_upgrade_connection)r   ÚheadersÚpaths      r   r   z(WSConnection.initiate_upgrade_connection1   s   € ð 	�‰×2Ñ2°7¸DÕAr   c                óÔ   — d}| j                   €;|| j                  j                  |«      z  }| j                  j                   | _         |S || j                   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   ÚeventÚdatas      r   r!   zWSConnection.send6   sd   € ð ˆØ�?‰?Ð"Ø�D—N‘N×'Ñ'¨Ó.Ñ.ˆDØ"Ÿn™n×7Ñ7ˆDŒOð ˆð �D—O‘O×(Ñ(¨Ó/Ñ/ˆDØˆr   c                óÀ   — | j                   €7| j                  j                  |«       | j                  j                   | _         y| j                   j                  |«       y)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   sC   € ð �?‰?Ð"Ø�N‰N×'Ñ'¨Ô-Ø"Ÿn™n×7Ñ7ˆD�Oà�O‰O×(Ñ(¨Õ.r   c              #  ó¶   K  — | j                   j                  «       E d{  –—†  | j                  �#| j                  j                  «       E d{  –—†  yy7 Œ47 Œ­w)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   sL   è ø€ ð —>‘>×(Ñ(Ó*×*Ð*Ø�?‰?Ð&Ø—‘×-Ñ-Ó/×/Ñ/ð 'ð 	+øà/ús!   ‚A A¡-AÁAÁAÁAN)r   r   ÚreturnÚNone)r(   r   )r   r   r   zbytes | strr(   r)   )r"   r   r(   Úbytes)r#   zbytes | Noner(   r)   )r(   zGenerator[Event, None, None])Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r!   r%   r'   © r   r   r   r      sP   „ ñó	2ð ò%ó ð%ðBØðBØ&1ðBà	óBó
ó&/ô	0r   r   )r   r   N)r.   Ú
__future__r   Útypingr   r   r   r   r   r   r	   Úcollections.abcr
   r'   r   r   Ú__version__r   Ú__all__r0   r   r   ú<module>r6      s@   ðñõ #å  ç CÑ CÝ #áÝ)åÝà€÷J0ñ J0ðZ -�r   