Class Peer
Manages an active network connection.
Inheritance
Namespace: SuperNet.Netcode.Transport
Assembly: cs.temp.dll.dll
Syntax
public class Peer : IDisposable
Fields
Config
Configuration values for this peer.
Declaration
public readonly PeerConfig Config
Field Value
Type | Description |
---|---|
PeerConfig |
Host
Host used to manage this peer.
Declaration
public readonly Host Host
Field Value
Type | Description |
---|---|
Host |
Remote
Address this peer is connected to.
Declaration
public readonly IPEndPoint Remote
Field Value
Type | Description |
---|---|
IPEndPoint |
Statistics
Packet statistics.
Declaration
public readonly PeerStatistics Statistics
Field Value
Type | Description |
---|---|
PeerStatistics |
Properties
Connected
True if messages can be sent.
Declaration
public bool Connected { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Connecting
True if peer is in the process of connecting.
Declaration
public bool Connecting { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
DeltaAverage
Average clock difference in last 16 bits of ticks between peers.
Declaration
public double DeltaAverage { get; }
Property Value
Type | Description |
---|---|
System.Double |
DeltaLast
Last clock difference in last 16 bits of ticks between peers.
Declaration
public ushort DeltaLast { get; }
Property Value
Type | Description |
---|---|
System.UInt16 |
Disposed
True if peer has been disposed.
Declaration
public bool Disposed { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Listener
Listener used by this peer.
Declaration
public IPeerListener Listener { get; }
Property Value
Type | Description |
---|---|
IPeerListener |
RTT
Current round trip time (ping) in milliseconds.
Declaration
public ushort RTT { get; }
Property Value
Type | Description |
---|---|
System.UInt16 |
Methods
Disconnect(IWritable)
Disconnect by sending a disconnect message.
Declaration
public void Disconnect(IWritable message = null)
Parameters
Type | Name | Description |
---|---|---|
IWritable | message | Disconnect message to include or null if none. |
DisconnectAsync(IWritable)
Disconnect by sending a disconnect message.
Declaration
public Task DisconnectAsync(IWritable message = null)
Parameters
Type | Name | Description |
---|---|---|
IWritable | message | Disconnect message to include or null if none. |
Returns
Type | Description |
---|---|
Task |
Dispose()
Instantly dispose of all resources held by this peer.
Declaration
public void Dispose()
Send(IMessage, IMessageListener)
Queue a message for sending and return a sent message handle.
Declaration
public MessageSent Send(IMessage message, IMessageListener listener = null)
Parameters
Type | Name | Description |
---|---|---|
IMessage | message | Message to send. |
IMessageListener | listener | Message listener to use or null if not used. |
Returns
Type | Description |
---|---|
MessageSent | Sent message handle. |
SetListener(IPeerListener)
Replace the current listener with a new one.
Declaration
public IPeerListener SetListener(IPeerListener listener)
Parameters
Type | Name | Description |
---|---|---|
IPeerListener | listener | Listener to replace with. |
Returns
Type | Description |
---|---|
IPeerListener | The old PeerListener. |