
    ,hG                     p    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y)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y)WSConnectionzN
    Represents the local end of a WebSocket connection to a remote peer.
    connection_typereturnNc                 `    |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)selfr   s     R/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/wsproto/__init__.py__init__zWSConnection.__init__   s)     &)>)>>%o604    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   headerspathc                 <    | j                   j                  ||       y )N)r   initiate_upgrade_connection)r   r   r   s      r   r    z(WSConnection.initiate_upgrade_connection+   s     	227DAr   eventc                     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   r!   datas      r   r#   zWSConnection.send0   sd     ??"DNN''..D"nn77DO  DOO((//Dr   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_dataC   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.eventsR   sL      >>((***??&--/// ' 	+/s!   AA-AAAA)__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 % % %BB&+E3J&7B	B
% E &/% /T /	0	%t"34 	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  # J0 J0Z -r   