mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-12-04 23:33:46 +03:00
f5f0c84553
Reduce abstraction leaks. Now the transport can hold any state, rather than just the tag. It's also responsible to initialize on the first connection, and they can be cleanly reset. asyncio connections are no longer used, in favour of raw sockets, which should avoid some annoyances. For the time being, more obscure transport modes have been removed, as well as proxy support, until further cleaning is done.
18 lines
393 B
Python
18 lines
393 B
Python
import abc
|
|
|
|
|
|
class Transport(abc.ABC):
|
|
# Should return a newly-created instance of itself
|
|
@abc.abstractmethod
|
|
def recreate_fresh(self):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def pack(self, input: bytes) -> bytes:
|
|
pass
|
|
|
|
# Should raise EOFError if it does not have enough bytes
|
|
@abc.abstractmethod
|
|
def unpack(self, input: bytes) -> (int, bytes):
|
|
pass
|