Use RawConnection.read

Instead of accessing its reader and writer directly.

TODO: considering add `ReaderWriterCloser` interface and let connection
and stream inherit from it.
This commit is contained in:
mhchia
2019-08-20 18:09:36 +08:00
parent 0b466ddc86
commit ef476e555b
9 changed files with 22 additions and 31 deletions

View File

@ -23,8 +23,6 @@ class BaseSession(ISecureConn):
self.remote_permanent_pubkey = None
self.initiator = self.conn.initiator
self.writer = self.conn.writer
self.reader = self.conn.reader
# TODO clean up how this is passed around?
def next_stream_id(self) -> int:
@ -33,8 +31,8 @@ class BaseSession(ISecureConn):
async def write(self, data: bytes) -> None:
await self.conn.write(data)
async def read(self) -> bytes:
return await self.conn.read()
async def read(self, n: int = -1) -> bytes:
return await self.conn.read(n)
def close(self) -> None:
self.conn.close()