pub struct IncomingMultiChannel<P, R> { /* private fields */ }
Expand description
An IncomingMultiChannel
is established for each incoming TCP connection.
The local party will act as the server for the remote client.
The demux
part takes messages from the incoming connection and dispatches
to the implementing protocols. If the protocol doesn’t exist, a server
session is instantiated to handle the messages.
The mux
part listens for outgoing messages from all instantiated server
sessions, relaying responses to the client.
Implementations§
Source§impl<P: Ord + Copy + Debug, R> IncomingMultiChannel<P, R>
impl<P: Ord + Copy + Debug, R> IncomingMultiChannel<P, R>
Sourcepub fn new(
tx: Sender<MultiMessage<P, R>>,
rx: Receiver<MultiMessage<P, R>>,
) -> Self
pub fn new( tx: Sender<MultiMessage<P, R>>, rx: Receiver<MultiMessage<P, R>>, ) -> Self
Create a new MultiChannel
by passing it the channels it can use to
send/receive messages to/from the underlying network connection.
Sourcepub async fn run<F>(self, init_server: F)
pub async fn run<F>(self, init_server: F)
Start consuming messages from the client, creating new protocol handlers where one doesn’t exist already.
We must also listen to an internal channel that signals the abortion of the whole connection due to some protocol violation.
init_server
should initiate the server side of the protocol, listening
to incoming messages from the client; it should return the channels we
can send the client messages to, and receive the replies over. When
sending or receiving from these channels fail, the protocol is over
and should be removed.