NetworkManager
A static class in Root.Township, Alta.Networking.
Static owner of the network transport (KCP) and all sockets. Pumps receiving in Update and sending in LateUpdate, and keeps packet and error counters for profiling.
- Listed in Networking and servers
- Documented in Sockets and connections, Update modules
Fields
| Member | What it is |
|---|---|
static bool IsTransportStarted | Whether the transport and update loops have started. |
static AverageNumber ReceivingMs | Average time spent receiving per frame. |
static AverageNumber SendingMs | Average time spent sending per frame. |
static ITransport Transport | The transport in use, created on first socket. |
9 private and internal fields
| Member | What it is |
|---|---|
private static Logger logger | Logger for this class. |
private static IUnityUpdateMethod receive | Update handle cleared by Terminate; never set, so Terminate does not stop Receive. |
private static IUnityUpdateMethod receiveUpdateMethod | Update handle for Receive. |
private static readonly UpdateModule receivingModule | Update module (Update) that runs Receive, included in server profiling. |
private static IUnityUpdateMethod send | Update handle cleared by Terminate; never set, so Terminate does not stop Send. |
private static readonly UpdateModule sendingModule | Update module (LateUpdate) that runs Send, included in server profiling. |
private static IUnityUpdateMethod sendUpdateMethod | Update handle for Send. |
private static readonly List<ISocket> sockets | All open sockets, updated each frame. |
private static readonly Stopwatch timer | Stopwatch used to time send and receive. |
Properties
1 private and internal property
| Member | What it is |
|---|---|
private static NetworkingSettings Settings { get; } | The global NetworkingSettings. |
Methods
| Member | What it is |
|---|---|
static void CloseSocket(ISocket socket) | Removes and disposes a socket. |
static ISocket CreateSocket(bool isServer, TransportSystem transportSystem, int socketPort = 0) | Starts the transport if needed and creates a socket (server sockets on the given port). |
static void Terminate() | Disposes every socket and shuts the transport down. |
6 private and internal methods
| Member | What it is |
|---|---|
private static void CreateTransport() | Creates the transport from NetworkingSettings; only KCP is supported, anything else throws. |
private static void EnsureNetworkingHasStarted() | On first use, creates the transport, its channels and the send and receive update calls. |
private static void Receive() | Each Update, runs every socket's receive and records the time in ReceivingMs. |
private static void Send() | Each LateUpdate, runs every socket's send and records the time in SendingMs. |
private static void SetupSendReceive(Connection _ = null) | Registers Receive and Send on their update modules, replacing any earlier registration. |
private static void SetupTransportChannels() | Creates a transport channel for each channel in the settings. |