diff --git a/muxer/muxed_connection.py b/muxer/muxed_connection.py index 26c80f5c..c0b99263 100644 --- a/muxer/muxed_connection.py +++ b/muxer/muxed_connection.py @@ -1,6 +1,6 @@ -from .muxed_connection_interface import IMuxedConnection +from .muxed_connection_interface import IMuxedConn -class MuxedConnection(IMuxedConnection): +class MuxedConn(IMuxedConn): """ reference: https://github.com/libp2p/go-mplex/blob/master/multiplex.go """ @@ -26,7 +26,7 @@ class MuxedConnection(IMuxedConnection): """ pass - def open_stream(self): + def open_stream(self, protocol_id, stream_name): """ creates a new muxed_stream :return: a new stream @@ -38,4 +38,4 @@ class MuxedConnection(IMuxedConnection): accepts a muxed stream opened by the other end :return: the accepted stream """ - pass + pass diff --git a/muxer/muxed_connection_interface.py b/muxer/muxed_connection_interface.py index cf125918..df1694a0 100644 --- a/muxer/muxed_connection_interface.py +++ b/muxer/muxed_connection_interface.py @@ -16,9 +16,11 @@ class IMuxedConn(ABC): pass @abstractmethod - def open_stream(self): + def open_stream(self, protocol_id, stream_name): """ creates a new muxed_stream + :param protocol_id: id to be associated with stream + :param stream_name: name as part of identifier :return: a new stream """ pass @@ -29,4 +31,4 @@ class IMuxedConn(ABC): accepts a muxed stream opened by the other end :return: the accepted stream """ - pass + pass diff --git a/muxer/muxed_stream.py b/muxer/muxed_stream.py index be37d58a..92624e5f 100644 --- a/muxer/muxed_stream.py +++ b/muxer/muxed_stream.py @@ -1,11 +1,12 @@ from .muxed_stream_interface import IMuxedStream class MuxedStream(IMuxedStream): - """ - reference: https://github.com/libp2p/go-mplex/blob/master/stream.go - """ - def __init__(self, stream_id, stream_name): - self.id = stream_id + """ + reference: https://github.com/libp2p/go-mplex/blob/master/stream.go + """ + + def __init__(self, protocol_id, stream_name): + self.protocol_id = protocol_id self.name = stream_name def read(self): @@ -15,7 +16,7 @@ class MuxedStream(IMuxedStream): pass def close(self): - pass + pass def reset(self): """ diff --git a/muxer/muxed_stream_interface.py b/muxer/muxed_stream_interface.py index 0ac3ec9a..2c9bc25f 100644 --- a/muxer/muxed_stream_interface.py +++ b/muxer/muxed_stream_interface.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from datetime import time +# from datetime import time class IMuxedStream(ABC): diff --git a/muxer/smux_multiplex.py b/muxer/smux_multiplex.py index ae7feb97..6239ad73 100644 --- a/muxer/smux_multiplex.py +++ b/muxer/smux_multiplex.py @@ -25,19 +25,19 @@ class Multiplex(object): """ return self.muxed_conn.is_closed() - def open_stream(self): + def open_stream(self, protocol_id, stream_name): """ creates a new muxed_stream :return: a new stream """ - return self.muxed_conn.open_stream() + return self.muxed_conn.open_stream(protocol_id, stream_name) def accept_stream(self, _muxed_stream): - """ - accepts a muxed stream opened by the other end - :param _muxed_stream: stream to be accepted + """ + accepts a muxed stream opened by the other end + :param _muxed_stream: stream to be accepted :return: the accepted stream - """ + """ pass # def new_conn(raw_conn, is_server): diff --git a/muxer/stream_muxer_interface.py b/muxer/stream_muxer_interface.py deleted file mode 100644 index e69de29b..00000000