Class NetSystem¶
Namespace: Apogee.Network
Assembly: Apogee.Network.dll
The game's network: connections to other programs over UDP, with encryption, in order and reliably or not as each message asks (GameNetworkingSockets, Valve's open-source transport). One side
public sealed class NetSystem : EngineObject, IDisposable
Inheritance¶
object ← EngineObject ← NetSystem
Implements¶
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()
Remarks¶
Call
Constructors¶
NetSystem(NetOptions?)¶
Starts the library. If it cannot be started the system is inactive,
public NetSystem(NetOptions? options = null)
Parameters¶
options NetOptions?
Properties¶
Class¶
What the registry knows about this object's class.
public override ClassInfo Class { get; }
Property Value¶
Connected¶
A connection is up: the one that
public Signal<NetConnection> Connected { get; }
Property Value¶
ConnectionRequested¶
Somebody wants to connect to the port we listen on, with their address. The connection is accepted when the handlers return, unless one of them called
public Signal<NetConnection, string> ConnectionRequested { get; }
Property Value¶
Disconnected¶
A connection ended: the other side closed it, it timed out, or a connection that was being made failed. With the reason's text and code (1000 and up: the other side's own).
public Signal<NetConnection, string, int> Disconnected { get; }
Property Value¶
Signal<NetConnection, string, int>
IsActive¶
True when the library started: connections can be made. False means every call does nothing.
public bool IsActive { get; }
Property Value¶
ListeningPort¶
The port being listened on (the one asked for, or the free one the library chose), or 0.
public int ListeningPort { get; }
Property Value¶
Message¶
A message arrived on a connection, as text, on a lane.
public Signal<NetConnection, string, int> Message { get; }
Property Value¶
Signal<NetConnection, string, int>
Status¶
Why the system is not active, or "Ready.".
public string Status { get; }
Property Value¶
Methods¶
Connect(string)¶
Starts connecting to host:port (an IP address, [::1]:27020 for IPv6, or a name, which is looked up first and so can block for a moment). The result is a
public NetConnection? Connect(string address)
Parameters¶
address string
Returns¶
Create()¶
Makes a network system of its own from a script: for tests, which talk to themselves over the loopback interface. A game's own is the global net.
public static NetSystem Create()
Returns¶
CreateInactive()¶
Makes an inactive network system from a script: for tests of what scripts see when there is no library.
public static NetSystem CreateInactive()
Returns¶
Dispose()¶
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
IsInstalled()¶
Whether the library can be loaded: false on a machine without GameNetworkingSockets next to the program.
public static bool IsInstalled()
Returns¶
Listen(int)¶
Listens on a UDP port, for IPv4 and IPv6 (0: any free port). Returns the port, or 0 if it could not be opened (it is in use, or the system is inactive). One port at a time: listening again closes the first (its connections stay).
public int Listen(int port = 0)
Parameters¶
port int
Returns¶
OnDestroyed()¶
protected override void OnDestroyed()
StopListening()¶
Stops accepting new connections; the ones made stay.
public void StopListening()
Update()¶
Once a frame: runs the library's callbacks and emits what happened as signals, in order: connections made, messages, connections ended.
public void Update()
BytesReceived¶
A message arrived, as bytes: for C#, which can send and receive anything. Called before
public event Action<NetConnection, byte[], int>? BytesReceived
Event Type¶
Action<NetConnection, byte[], int>?