muxer scaffolding
This commit is contained in:
parent
19650d0f72
commit
8756320e85
|
@ -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
|
reference: https://github.com/libp2p/go-mplex/blob/master/multiplex.go
|
||||||
"""
|
"""
|
||||||
|
@ -26,7 +26,7 @@ class MuxedConnection(IMuxedConnection):
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def open_stream(self):
|
def open_stream(self, protocol_id, stream_name):
|
||||||
"""
|
"""
|
||||||
creates a new muxed_stream
|
creates a new muxed_stream
|
||||||
:return: a new stream
|
:return: a new stream
|
||||||
|
|
|
@ -16,9 +16,11 @@ class IMuxedConn(ABC):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def open_stream(self):
|
def open_stream(self, protocol_id, stream_name):
|
||||||
"""
|
"""
|
||||||
creates a new muxed_stream
|
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
|
:return: a new stream
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
from .muxed_stream_interface import IMuxedStream
|
from .muxed_stream_interface import IMuxedStream
|
||||||
|
|
||||||
class MuxedStream(IMuxedStream):
|
class MuxedStream(IMuxedStream):
|
||||||
"""
|
"""
|
||||||
reference: https://github.com/libp2p/go-mplex/blob/master/stream.go
|
reference: https://github.com/libp2p/go-mplex/blob/master/stream.go
|
||||||
"""
|
"""
|
||||||
def __init__(self, stream_id, stream_name):
|
|
||||||
self.id = stream_id
|
def __init__(self, protocol_id, stream_name):
|
||||||
|
self.protocol_id = protocol_id
|
||||||
self.name = stream_name
|
self.name = stream_name
|
||||||
|
|
||||||
def read(self):
|
def read(self):
|
||||||
|
@ -15,7 +16,7 @@ class MuxedStream(IMuxedStream):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from datetime import time
|
# from datetime import time
|
||||||
|
|
||||||
class IMuxedStream(ABC):
|
class IMuxedStream(ABC):
|
||||||
|
|
||||||
|
|
|
@ -25,19 +25,19 @@ class Multiplex(object):
|
||||||
"""
|
"""
|
||||||
return self.muxed_conn.is_closed()
|
return self.muxed_conn.is_closed()
|
||||||
|
|
||||||
def open_stream(self):
|
def open_stream(self, protocol_id, stream_name):
|
||||||
"""
|
"""
|
||||||
creates a new muxed_stream
|
creates a new muxed_stream
|
||||||
:return: a new 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):
|
def accept_stream(self, _muxed_stream):
|
||||||
"""
|
"""
|
||||||
accepts a muxed stream opened by the other end
|
accepts a muxed stream opened by the other end
|
||||||
:param _muxed_stream: stream to be accepted
|
:param _muxed_stream: stream to be accepted
|
||||||
:return: the accepted stream
|
:return: the accepted stream
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# def new_conn(raw_conn, is_server):
|
# def new_conn(raw_conn, is_server):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user