mixx
This commit is contained in:
parent
7abd6e9e13
commit
8cf17a4c12
@ -10,10 +10,11 @@ from .poputils import InvalidCommand, parse_command, err, Command, ClientQuit, C
|
|||||||
Request, MailEntry, get_mail, get_mails_list, MailList
|
Request, MailEntry, get_mail, get_mails_list, MailList
|
||||||
|
|
||||||
|
|
||||||
|
# noinspection PyProtectedMember
|
||||||
@dataclass
|
@dataclass
|
||||||
class Session:
|
class Session:
|
||||||
reader: asyncio.StreamReader
|
_reader: asyncio.StreamReader
|
||||||
writer: asyncio.StreamWriter
|
_writer: asyncio.StreamWriter
|
||||||
|
|
||||||
# common state
|
# common state
|
||||||
all_sessions: ClassVar[Set] = set()
|
all_sessions: ClassVar[Set] = set()
|
||||||
@ -26,11 +27,11 @@ class Session:
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def reader(cls):
|
def reader(cls):
|
||||||
return cls.get().reader
|
return cls.get()._reader
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def writer(cls):
|
def writer(cls):
|
||||||
return cls.get().writer
|
return cls.get()._writer
|
||||||
|
|
||||||
|
|
||||||
async def next_req():
|
async def next_req():
|
||||||
@ -61,13 +62,11 @@ async def expect_cmd(*commands: Command):
|
|||||||
|
|
||||||
def write(data):
|
def write(data):
|
||||||
logging.debug(f"Server: {data}")
|
logging.debug(f"Server: {data}")
|
||||||
session: Session = Session.current_session.get()
|
Session.writer().write(data)
|
||||||
session.writer.write(data)
|
|
||||||
|
|
||||||
|
|
||||||
async def drain():
|
async def drain():
|
||||||
session: Session = Session.current_session.get()
|
await Session.writer().drain()
|
||||||
await session.writer.drain()
|
|
||||||
|
|
||||||
|
|
||||||
def validate_user_and_pass(username, password):
|
def validate_user_and_pass(username, password):
|
||||||
|
Loading…
Reference in New Issue
Block a user