Skip to content

Class NetConnection

Namespace: Apogee.Network
Assembly: Apogee.Network.dll

One connection to another program, made by or accepted by a . Messages are sent on it and arrive as signals of the .

public sealed class NetConnection : EngineObject

Inheritance

object ← EngineObject ← NetConnection

Inherited Members

EngineObject.IsAdopted, EngineObject.Handle, EngineObject.IsDestroyed, EngineObject.Class, EngineObject.Adopt(), EngineObject.TryGet(SlotHandle, out EngineObject), EngineObject.Destroy(), object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Fields

RefusedReason

The reason code of a connection that a handler of refused (the application range starts at 1000).

public const int RefusedReason = 1001

Field Value

int

Properties

Address

The other side's address (the one that was asked for, for a connection we made).

public string Address { get; }

Property Value

string

BytesIn

Bytes a second being received.

public float BytesIn { get; }

Property Value

float

BytesOut

Bytes a second being sent.

public float BytesOut { get; }

Property Value

float

Class

What the registry knows about this object's class.

public override ClassInfo Class { get; }

Property Value

ClassInfo

IsIncoming

True for a connection that somebody made to our port, false for one we made.

public bool IsIncoming { get; }

Property Value

bool

Ping

The round trip time in milliseconds, or -1 when it is not known yet.

public int Ping { get; }

Property Value

int

Quality

0 to 1: the share of our packets that arrive, as the other side measures it.

public float Quality { get; }

Property Value

float

State

public NetState State { get; }

Property Value

NetState

Methods

Close(string, bool)

Ends the connection. Messages still waiting are sent first when linger. The other side gets with reason; here no signal is emitted (we asked for it).

public void Close(string reason = "", bool linger = true)

Parameters

reason string

linger bool

ConfigureLanes(int)

Gives the connection count lanes: messages on one lane arrive in order and a slow one does not hold up the others. Before the first message.

public bool ConfigureLanes(int count)

Parameters

count int

Returns

bool

Refuse()

In a handler of : turns the connection down.

public void Refuse()

Send(string, bool, int)

Sends text (UTF-8) to the other side. reliable messages arrive, once and in order; the others may be lost, never twice, and are for what is out of date a moment later (positions). lane is the lane set by (0 is the default one). Returns false when it could not be queued.

public bool Send(string data, bool reliable = true, int lane = 0)

Parameters

data string

reliable bool

lane int

Returns

bool

SendBytes(ReadOnlySpan<byte>, bool, int)

Sends bytes: what does for text.

public bool SendBytes(ReadOnlySpan<byte> data, bool reliable = true, int lane = 0)

Parameters

data ReadOnlySpan<byte>

reliable bool

lane int

Returns

bool