Show / Hide Table of Contents

Class ConnectionManager

Manages the peer connections in a Swarm.

Inheritance
Object
ConnectionManager
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 ConnectionManager
Remarks

Enforces that only one connection exists to the Peer. This prevents the race condition when two simultaneously connect to each other.

TODO: Enforces a maximum number of open connections.

Properties

| Improve this Doc View Source

Connections

Gets the current active connections.

Declaration
public IEnumerable<PeerConnection> Connections { get; }
Property Value
Type Description
IEnumerable<PeerConnection>

Methods

| Improve this Doc View Source

Add(PeerConnection)

Adds a new connection.

Declaration
public PeerConnection Add(PeerConnection connection)
Parameters
Type Name Description
PeerConnection connection

The PeerConnection to add.

Returns
Type Description
PeerConnection

The connection that should be used.

Remarks

If a connection already exists to the peer, the specified connection is closed and existing connection is returned.

| Improve this Doc View Source

Clear()

Removes and closes all connections.

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

IsConnected(Peer)

Determines if a connection exists to the specified peer.

Declaration
public bool IsConnected(Peer peer)
Parameters
Type Name Description
Peer peer

Another peer.

Returns
Type Description
Boolean

true if there is a connection to the peer and the connection is active; otherwise false.

| Improve this Doc View Source

Remove(MultiHash)

Remove and close all connection to the peer ID.

Declaration
public bool Remove(MultiHash id)
Parameters
Type Name Description
MultiHash id

The ID of a Peer to remove.

Returns
Type Description
Boolean

true if a connection was removed; otherwise, false.

| Improve this Doc View Source

Remove(PeerConnection)

Remove a connection.

Declaration
public bool Remove(PeerConnection connection)
Parameters
Type Name Description
PeerConnection connection

The PeerConnection to remove.

Returns
Type Description
Boolean

true if the connection was removed; otherwise, false.

Remarks

The connection is removed from the list of connections and is closed.

| Improve this Doc View Source

TryGet(Peer, out PeerConnection)

Gets the connection to the peer.

Declaration
public bool TryGet(Peer peer, out PeerConnection connection)
Parameters
Type Name Description
Peer peer

A peer.

PeerConnection connection

The connection to the peer.

Returns
Type Description
Boolean

true if a connection exists; otherwise false.

Remarks

If the connection's underlaying Stream is closed, then the connection is removed.

Events

| Improve this Doc View Source

PeerDisconnected

Raised when a peer's connection is closed.

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