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 )zñClose 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 )z�Pause 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   )z‡Get 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 )zŠWrite 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 )zœWrite 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 )z•Close 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 )zÄClose 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    