Fix MplexStream error

When receiving a `NewStream`, the message of that packet is the
name of the stream, which should be handled, rather than letting it go
into the message queue.
This commit is contained in:
mhchia
2019-08-26 20:26:22 +08:00
parent 5b122d04b2
commit d59870ebbf
4 changed files with 25 additions and 34 deletions

View File

@ -10,6 +10,7 @@ class MplexStream(IMuxedStream):
reference: https://github.com/libp2p/go-mplex/blob/master/stream.go
"""
name: str
stream_id: int
initiator: bool
mplex_conn: IMuxedConn
@ -21,13 +22,16 @@ class MplexStream(IMuxedStream):
_buf: bytearray
def __init__(self, stream_id: int, initiator: bool, mplex_conn: IMuxedConn) -> None:
def __init__(
self, name: str, stream_id: int, initiator: bool, mplex_conn: IMuxedConn
) -> None:
"""
create new MuxedStream in muxer
:param stream_id: stream stream id
:param initiator: boolean if this is an initiator
:param mplex_conn: muxed connection of this muxed_stream
"""
self.name = name
self.stream_id = stream_id
self.initiator = initiator
self.mplex_conn = mplex_conn