Show / Hide Table of Contents

Class Muxer

Supports multiple protocols over a single channel (stream).

Inheritance
Object
Muxer
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: PeerTalk.Multiplex
Assembly: PeerTalk.dll
Syntax
public class Muxer
Remarks

See https://github.com/libp2p/mplex for the spec.

Fields

| Improve this Doc View Source

Substreams

The substreams that are open.

Declaration
public ConcurrentDictionary<long, Substream> Substreams
Field Value
Type Description
ConcurrentDictionary<Int64, Substream>

The key is stream ID and the value is a Substream.

Properties

| Improve this Doc View Source

Channel

The signle channel to exchange protocol messages.

Declaration
public Stream Channel { get; set; }
Property Value
Type Description
Stream

A Stream to exchange protocol messages.

| Improve this Doc View Source

Connection

The peer connection.

Declaration
public PeerConnection Connection { get; set; }
Property Value
Type Description
PeerConnection

The peer connection that owns this muxer.

| Improve this Doc View Source

Initiator

Determines if the muxer is the initiator.

Declaration
public bool Initiator { get; set; }
Property Value
Type Description
Boolean

true if the muxer is the initiator.

See Also
Receiver
| Improve this Doc View Source

NextStreamId

The next stream ID to create.

Declaration
public long NextStreamId { get; }
Property Value
Type Description
Int64

The session initiator allocates even IDs and the session receiver allocates odd IDs.

| Improve this Doc View Source

Receiver

Determines if the muxer is the receiver.

Declaration
public bool Receiver { get; set; }
Property Value
Type Description
Boolean

true if the muxer is the receiver.

See Also
Initiator

Methods

| Improve this Doc View Source

AcquireWriteAccessAsync()

Acquire permission to write to the Channel.

Declaration
public Task<IDisposable> AcquireWriteAccessAsync()
Returns
Type Description
Task<IDisposable>

A task that represents the asynchronous get operation. The task's value is an IDisposable that releases the lock.

| Improve this Doc View Source

CreateStreamAsync(String, CancellationToken)

Creates a new stream with the specified name.

Declaration
public Task<Substream> CreateStreamAsync(string name = "", CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name

A name for the stream.

CancellationToken cancel

Is used to stop the task. When cancelled, the TaskCanceledException is raised.

Returns
Type Description
Task<Substream>

A duplex stream.

| Improve this Doc View Source

ProcessRequestsAsync(CancellationToken)

Read the multiplex packets.

Declaration
public Task ProcessRequestsAsync(CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
CancellationToken cancel
Returns
Type Description
Task
Remarks

A background task that reads and processes the multiplex packets while the Channel is open and not cancel.

Any encountered errors will close the Channel.

| Improve this Doc View Source

RemoveStreamAsync(Substream, CancellationToken)

Remove the stream.

Declaration
public Task<Substream> RemoveStreamAsync(Substream stream, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
Substream stream
CancellationToken cancel
Returns
Type Description
Task<Substream>
Remarks

Internal method called by Substream.Dispose().

Events

| Improve this Doc View Source

SubstreamClosed

Raised when the remote end closes a stream.

Declaration
public event EventHandler<Substream> SubstreamClosed
Event Type
Type Description
EventHandler<Substream>
| Improve this Doc View Source

SubstreamCreated

Raised when the remote end creates a new stream.

Declaration
public event EventHandler<Substream> SubstreamCreated
Event Type
Type Description
EventHandler<Substream>
  • Improve this Doc
  • View Source
Back to top Generated by DocFX