
     fG                     x    d Z ddlmZmZmZ ddlmZmZmZ 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.
    )	GeneratorOptionalUnion   )
ConnectionConnectionStateConnectionType)Event)H11Handshake)Headersz1.2.0c                       e Zd ZdZdeddfdZedefd            Zde	de
eef         dd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 )WSConnectionzN
    Represents the local end of a WebSocket connection to a remote peer.
    connection_typereturnNc                 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     S/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/wsproto/__init__.py__init__zWSConnection.__init__   s-     &)>>%o6604    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   headerspathc                 <    | j                             ||           d S )N)r   initiate_upgrade_connection)r   r   r   s      r   r    z(WSConnection.initiate_upgrade_connection+   s"     	227DAAAAAr   eventc                     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.send0   sX     ?"DN''...D"n7DOODO((///Dr   r$   c                     | 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_dataC   sN     ?"N''---"n7DOOOO((.....r   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.eventsR   sj       >((*********?&--/////////// '&r   )__name__
__module____qualname____doc__r	   r   propertyr   r   r   r   bytesstrr    r
   r#   r   r&   r   r(    r   r   r   r      s        	5 	54 	5 	5 	5 	5 % % % % X%BB&+E3J&7B	B B B B
% E    &/% /T / / / /	0	%t"34 	0 	0 	0 	0 	0 	0r   r   )r	   r   N)r,   typingr   r   r   r   r   r   r	   r(   r
   r   r   r   __version__r   __all__r0   r   r   <module>r4      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0Z -r   