rename muxed_conn
This commit is contained in:
parent
4e2749c915
commit
e047752d82
|
@ -1,45 +0,0 @@
|
|||
from .muxed_connection import MuxedConn
|
||||
|
||||
|
||||
class Multiplex(object):
|
||||
"""
|
||||
muxing logic currently lives in MuxedConn
|
||||
reference: https://github.com/whyrusleeping/go-smux-multiplex/blob/master/multiplex.go
|
||||
"""
|
||||
def __init__(self, conn, initiator):
|
||||
"""
|
||||
:param conn: an instance of raw connection
|
||||
:param initiator: boolean to prevent multiplex with self
|
||||
"""
|
||||
self.muxed_conn = MuxedConn(conn, initiator)
|
||||
|
||||
def close(self):
|
||||
"""
|
||||
close the stream muxer and underlying raw connection
|
||||
"""
|
||||
return self.muxed_conn.close()
|
||||
|
||||
def is_closed(self):
|
||||
"""
|
||||
check connection is fully closed
|
||||
:return: true if successful
|
||||
"""
|
||||
return self.muxed_conn.is_closed()
|
||||
|
||||
def open_stream(self, protocol_id, stream_name):
|
||||
"""
|
||||
creates a new muxed_stream
|
||||
:return: a new 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
|
||||
:return: the accepted stream
|
||||
"""
|
||||
pass
|
||||
|
||||
# def new_conn(raw_conn, is_server):
|
||||
# pass
|
|
@ -1,10 +1,10 @@
|
|||
import asyncio
|
||||
from .utils import encode_uvarint, decode_uvarint
|
||||
from .muxed_connection_interface import IMuxedConn
|
||||
from .muxed_stream import MuxedStream
|
||||
from .mplex_stream import MplexStream
|
||||
from ..muxed_connection_interface import IMuxedConn
|
||||
|
||||
|
||||
class MuxedConn(IMuxedConn):
|
||||
class Mplex(IMuxedConn):
|
||||
"""
|
||||
reference: https://github.com/libp2p/go-mplex/blob/master/multiplex.go
|
||||
"""
|
||||
|
@ -57,7 +57,7 @@ class MuxedConn(IMuxedConn):
|
|||
:param multi_addr: multi_addr that stream connects to
|
||||
:return: a new stream
|
||||
"""
|
||||
stream = MuxedStream(stream_id, multi_addr, self)
|
||||
stream = MplexStream(stream_id, multi_addr, self)
|
||||
self.streams[stream_id] = stream
|
||||
return stream
|
||||
|
||||
|
@ -69,7 +69,7 @@ class MuxedConn(IMuxedConn):
|
|||
# TODO update to pull out protocol_id from message
|
||||
protocol_id = "/echo/1.0.0"
|
||||
stream_id = await self.stream_queue.get()
|
||||
stream = MuxedStream(stream_id, False, self)
|
||||
stream = MplexStream(stream_id, False, self)
|
||||
return stream, stream_id, protocol_id
|
||||
|
||||
async def send_message(self, flag, data, stream_id):
|
|
@ -1,8 +1,8 @@
|
|||
from .muxed_stream_interface import IMuxedStream
|
||||
from .constants import HEADER_TAGS
|
||||
from ..muxed_stream_interface import IMuxedStream
|
||||
|
||||
|
||||
class MuxedStream(IMuxedStream):
|
||||
class MplexStream(IMuxedStream):
|
||||
"""
|
||||
reference: https://github.com/libp2p/go-mplex/blob/master/stream.go
|
||||
"""
|
|
@ -1,4 +1,4 @@
|
|||
from muxer.mplex.muxed_connection import MuxedConn
|
||||
from stream_muxer.mplex.mplex import Mplex
|
||||
|
||||
|
||||
class TransportUpgrader():
|
||||
|
@ -24,4 +24,4 @@ class TransportUpgrader():
|
|||
|
||||
# For PoC, no security, default to mplex
|
||||
# TODO do exchange to determine multiplexer
|
||||
return MuxedConn(conn, initiator)
|
||||
return Mplex(conn, initiator)
|
||||
|
|
Loading…
Reference in New Issue
Block a user