refactoring stream IDs

This commit is contained in:
Robert Zajac
2018-11-29 13:42:05 -05:00
parent 49bc5d2f65
commit 803999310a
7 changed files with 72 additions and 27 deletions

View File

@ -2,13 +2,24 @@ from .raw_connection_interface import IRawConnection
class RawConnection(IRawConnection):
# pylint: disable=too-few-public-methods
def __init__(self, ip, port, reader, writer):
def __init__(self, ip, port, reader, writer, initiator):
# pylint: disable=too-many-arguments
self.conn_ip = ip
self.conn_port = port
self.reader = reader
self.writer = writer
self._next_id = 0 if initiator else 1
self.initiator = initiator
def close(self):
self.writer.close()
def next_stream_id(self):
"""
Get next available stream id
:return: next available stream id for the connection
"""
next_id = self._next_id
self._next_id += 2
return next_id