3
uQhÁ  ã               @   s<   d dl Z ddlmZmZ G dd„ deƒZG dd„ deƒZdS )é    Né   )Ú
ConnectionÚPacketCodecc               @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )ÚAbridgedPacketCodecó   ïs   ïïïïc             C   s<   t |ƒd? }|dk r"tjd|ƒ}ndtj|ddƒ }|| S )Né   é   ÚBó   é   Úlittle)ÚlenÚstructÚpackÚintÚto_bytes)ÚselfÚdataÚlength© r   úK/tmp/pip-build-2nz6shyl/telethon/telethon/network/connection/tcpabridged.pyÚencode_packet
   s
    z!AbridgedPacketCodec.encode_packetc             Ã   sX   t jd|jdƒI d H ƒd }|dkrDt jd|jdƒI d H d ƒd }|j|d> ƒI d H S )	Nz<Br   r   r   z<ir   ó    r   )r   ÚunpackZreadexactly)r   Úreaderr   r   r   r   Úread_packet   s
    zAbridgedPacketCodec.read_packetN)Ú__name__Ú
__module__Ú__qualname__ÚtagZobfuscate_tagr   r   r   r   r   r   r      s   r   c               @   s   e Zd ZdZeZdS )ÚConnectionTcpAbridgedz©
    This is the mode with the lowest overhead, as it will
    only require 1 byte if the packet length is less than
    508 bytes (127 << 2, which is very common).
    N)r   r   r   Ú__doc__r   Zpacket_codecr   r   r   r   r       s   r    )r   Ú
connectionr   r   r   r    r   r   r   r   Ú<module>   s   