o
    j`                     @   s(   d dl mZ d dlZG dd deZdS )    )	TransportNc                   @   s   e Zd ZdZd%ddZd%ddZdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zd&ddZdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ ZdS )'UNITransportzBase class for WSNET transport.Nc                 C   s2   t |  d| _d| _|| _d| _d | _d| _d S )Ni  )r   r   F)r   __init__write_buffer_sizeread_buffer_sizecomms_write_buffer_limits	_protocol
_isclosing)self
connectionextra r   /root/aizidognhua/tmp/workspace/projects/ec89d86c-575f-41c9-af57-ac45cbdbf775/venv/lib/python3.10/site-packages/asysocks/unicomm/common/transport.pyr      s   

zUNITransport.__init__c                 C   s   t d|| | j||S )z#Get optional transport information.	Extrainfo)printr   get_extra_info)r   namedefaultr   r   r   r      s   zUNITransport.get_extra_infoc                 C      | j S )z2Return True if the transport is closing or closed.)r
   r   r   r   r   
is_closing      zUNITransport.is_closingc                 C   s   d| _ t| j }dS )zClose the transport.
		Buffered data will be flushed asynchronously.  No more data
		will be received.  After all buffered data is flushed, the
		protocol's connection_lost() method will (eventually) be
		called with None as its argument.
		TN)r
   asynciocreate_taskr   closer   xr   r   r   r      s   zUNITransport.closec                 C   s   || j _dS )zSet a new protocol.Nr   protocol)r   r   r   r   r   set_protocol%      zUNITransport.set_protocolc                 C   s   | j jS )zReturn the current protocol.r   r   r   r   r   get_protocol*   s   zUNITransport.get_protocolc                 C   s   | j j S )z*Return True if the transport is receiving.)r   read_resumeis_setr   r   r   r   
is_reading.   r!   zUNITransport.is_readingc                 C   s   t | j }dS )zPause the receiving end.
		No data will be passed to the protocol's data_received()
		method until resume_reading() is called.
		N)r   r   r   pause_readingr   r   r   r   r&   3   s   zUNITransport.pause_readingc                 C   s   | j j  dS )zrResume the receiving end.
		Data received will once again be passed to the protocol's
		data_received() method.
		N)r   r#   setr   r   r   r   resume_reading;   s   zUNITransport.resume_readingc                 C   s   ||f| _ dS )aJ  Set the high- and low-water limits for write flow control.
		These two values control when to call the protocol's
		pause_writing() and resume_writing() methods.  If specified,
		the low-water limit must be less than or equal to the
		high-water limit.  Neither value can be negative.
		The defaults are implementation-specific.  If only the
		high-water limit is given, the low-water limit defaults to an
		implementation-specific value less than or equal to the
		high-water limit.  Setting high to zero forces low to zero as
		well, and causes pause_writing() to be called whenever the
		buffer becomes non-empty.  Setting low to zero causes
		resume_writing() to be called only once the buffer is empty.
		Use of zero for either limit is generally sub-optimal as it
		reduces opportunities for doing I/O and computation
		concurrently.
		Nr   )r   highlowr   r   r   set_write_buffer_limitsC   s   z$UNITransport.set_write_buffer_limitsc                 C   r   )z,Return the current size of the write buffer.)r   r   r   r   r   get_write_buffer_sizeW   r   z"UNITransport.get_write_buffer_sizec                 C   r   )zGet the high and low watermarks for write flow control.
		Return a tuple (low, high) where low and high are
		positive number of bytes.r)   r   r   r   r   get_write_buffer_limits\   s   z$UNITransport.get_write_buffer_limitsc                 C   s   t | j|t   dS )zWrite some data bytes to the transport.
		This does not block; it buffers the data and arranges for it
		to be sent out asynchronously.
		N)r   run_coroutine_threadsafer   writeget_event_loop)r   datar   r   r   r0   c   s   zUNITransport.writec                 C   s   d |}| | dS )zWrite a list (or any iterable) of data bytes to the transport.
		The default implementation concatenates the arguments and
		calls write() on the result.
		    N)joinr0   )r   list_of_datar2   r   r   r   
writelinesk   s   
zUNITransport.writelinesc                 C   s   |  d dS )zClose the write end after flushing buffered data.
		(This is like typing ^D into a UNIX program reading from stdin.)
		Data may still be received.
		r3   N)r0   r   r   r   r   	write_eoft   s   zUNITransport.write_eofc                 C   s   dS )zAReturn True if this transport supports write_eof(), False if not.Tr   r   r   r   r   can_write_eof|   s   zUNITransport.can_write_eofc                 C   s   |    dS )zClose the transport immediately.
		Buffered data will be lost.  No more data will be received.
		The protocol's connection_lost() method will (eventually) be
		called with None as its argument.
		N)r   r   r   r   r   abort   s   zUNITransport.abort)N)NN)__name__
__module____qualname____doc__r   r   r   r   r    r"   r%   r&   r(   r,   r-   r.   r0   r6   r7   r8   r9   r   r   r   r   r      s&    

	
	r   )asyncio.transportsr   r   r   r   r   r   r   <module>   s    