Add delim_encode and delim_read

- Add `StreamCommunicator` and `RawConnectionCommunicator`, read/write
messages with delim codec, with `IMuxedStream` and `IRawConnection`
respectively.
- Use it in `Multiselect` and `MultiselectClient`.
This commit is contained in:
mhchia
2019-08-15 23:31:26 +08:00
committed by Kevin Mai-Husan Chia
parent 8cd23abfe2
commit 86d4ce1da8
11 changed files with 74 additions and 64 deletions

View File

@ -1,7 +1,9 @@
from abc import ABC, abstractmethod
from typing import Dict, Tuple
from libp2p.typing import NegotiableTransport, StreamHandlerFn, TProtocol
from libp2p.typing import StreamHandlerFn, TProtocol
from .multiselect_communicator_interface import IMultiselectCommunicator
class IMultiselectMuxer(ABC):
@ -23,7 +25,7 @@ class IMultiselectMuxer(ABC):
@abstractmethod
async def negotiate(
self, stream: NegotiableTransport
self, communicator: IMultiselectCommunicator
) -> Tuple[TProtocol, StreamHandlerFn]:
"""
Negotiate performs protocol selection