Show / Hide Table of Contents

Class PeerConnection

A connection between two peers.

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

A connection is used to exchange messages between peers.

Properties

| Improve this Doc View Source

BytesRead

Number of bytes read over the connection.

Declaration
public long BytesRead { get; }
Property Value
Type Description
Int64
| Improve this Doc View Source

BytesWritten

Number of bytes written over the connection.

Declaration
public long BytesWritten { get; }
Property Value
Type Description
Int64
| Improve this Doc View Source

IdentityEstablished

Signals that the identity of the remote endpoint is established.

Declaration
public TaskCompletionSource<Peer> IdentityEstablished { get; }
Property Value
Type Description
TaskCompletionSource<Peer>
Remarks

This can be awaited.

| Improve this Doc View Source

IsActive

Determines if the connection to the remote can be used.

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

true if the connection is active.

| Improve this Doc View Source

IsIncoming

Determine which peer (local or remote) initiated the connection.

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

true if the RemotePeer initiated the connection; otherwise, false.

| Improve this Doc View Source

LastUsed

When the connection was last used.

Declaration
public DateTime LastUsed { get; }
Property Value
Type Description
DateTime
| Improve this Doc View Source

LocalAddress

The local peer's end point.

Declaration
public MultiAddress LocalAddress { get; set; }
Property Value
Type Description
MultiAddress
| Improve this Doc View Source

LocalPeer

The local peer.

Declaration
public Peer LocalPeer { get; set; }
Property Value
Type Description
Peer
| Improve this Doc View Source

LocalPeerKey

The private key of the local peer.

Declaration
public Key LocalPeerKey { get; set; }
Property Value
Type Description
Key

Used to prove the identity of the LocalPeer.

| Improve this Doc View Source

MuxerEstablished

Signals that the muxer for the connection is established.

Declaration
public TaskCompletionSource<Muxer> MuxerEstablished { get; }
Property Value
Type Description
TaskCompletionSource<Muxer>
Remarks

This can be awaited.

| Improve this Doc View Source

Protocols

The protocols that the connection will handle.

Declaration
public Dictionary<string, Func<PeerConnection, Stream, CancellationToken, Task>> Protocols { get; }
Property Value
Type Description
Dictionary<String, Func<PeerConnection, Stream, CancellationToken, Task>>

The key is a protocol name, such as "/mplex/6.7.0". The value is a function that will process the protocol message.

See Also
AddProtocol(IPeerProtocol)
AddProtocols(IEnumerable<IPeerProtocol>)
| Improve this Doc View Source

RemoteAddress

The remote peer's end point.

Declaration
public MultiAddress RemoteAddress { get; set; }
Property Value
Type Description
MultiAddress
| Improve this Doc View Source

RemotePeer

The remote peer.

Declaration
public Peer RemotePeer { get; set; }
Property Value
Type Description
Peer
| Improve this Doc View Source

SecurityEstablished

Signals that the security for the connection is established.

Declaration
public TaskCompletionSource<bool> SecurityEstablished { get; }
Property Value
Type Description
TaskCompletionSource<Boolean>
Remarks

This can be awaited.

| Improve this Doc View Source

Stream

The duplex stream between the two peers.

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

Methods

| Improve this Doc View Source

AddProtocol(IPeerProtocol)

Add a protocol that the connection will handle.

Declaration
public void AddProtocol(IPeerProtocol protocol)
Parameters
Type Name Description
IPeerProtocol protocol

A peer protocol to add.

| Improve this Doc View Source

AddProtocols(IEnumerable<IPeerProtocol>)

Add a seequence of protocols that the connection will handle.

Declaration
public void AddProtocols(IEnumerable<IPeerProtocol> protocols)
Parameters
Type Name Description
IEnumerable<IPeerProtocol> protocols

The peer protocols to add.

| Improve this Doc View Source

Dispose()

Declaration
public void Dispose()
| Improve this Doc View Source

Dispose(Boolean)

TODO

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing
| Improve this Doc View Source

EstablishProtocolAsync(String, Stream, CancellationToken)

TODO:

Declaration
public Task EstablishProtocolAsync(string name, Stream stream, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
String name
Stream stream
CancellationToken cancel
Returns
Type Description
Task
| Improve this Doc View Source

EstablishProtocolAsync(String, CancellationToken)

TODO:

Declaration
public Task EstablishProtocolAsync(string name, CancellationToken cancel)
Parameters
Type Name Description
String name
CancellationToken cancel
Returns
Type Description
Task
| Improve this Doc View Source

InitiateAsync(IEnumerable<IEncryptionProtocol>, CancellationToken)

Establish the connection with the remote node.

Declaration
public Task InitiateAsync(IEnumerable<IEncryptionProtocol> securityProtocols, CancellationToken cancel = default(CancellationToken))
Parameters
Type Name Description
IEnumerable<IEncryptionProtocol> securityProtocols
CancellationToken cancel
Returns
Type Description
Task
Remarks

This should be called when the local peer wants a connection with the remote peer.

| Improve this Doc View Source

ReadMessagesAsync(Stream, CancellationToken)

Starts reading messages from the remote peer on the specified stream.

Declaration
public Task ReadMessagesAsync(Stream stream, CancellationToken cancel)
Parameters
Type Name Description
Stream stream
CancellationToken cancel
Returns
Type Description
Task
| Improve this Doc View Source

ReadMessagesAsync(CancellationToken)

Starts reading messages from the remote peer.

Declaration
public Task ReadMessagesAsync(CancellationToken cancel)
Parameters
Type Name Description
CancellationToken cancel
Returns
Type Description
Task

Events

| Improve this Doc View Source

Closed

Signals that the connection is closed (disposed).

Declaration
public event EventHandler<PeerConnection> Closed
Event Type
Type Description
EventHandler<PeerConnection>

Implements

System.IDisposable
  • Improve this Doc
  • View Source
Back to top Generated by DocFX