
    ,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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     _/var/www/system.tvplus.app.br/jogos/scrap/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27D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     ??"DNN''..D"nn77DO  DOO((//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     ??"NN''-"nn77DOOO((.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0Z -r   