class
Network
High-level networking class that wraps NetworkPeer to provide simple server/client functionality.
This is a convenience wrapper around NetworkPeer for applications that need basic networking without manual peer management. For Phase 1.1, this class provides only basic hosting/connecting functionality. High-level features like entity replication will be added in future phases.
Example usage as server:
Example usage as client:
For full control over networking, use NetworkPeer directly instead of this wrapper.
Public
Methods
IsHost
Checks if this instance is currently hosting a server.
Returns: True if hosting, false otherwise.
IsClient
Checks if this instance is a connected or connecting client.
Returns: True if client connection is active or being established, false otherwise.
Host
Starts hosting a server on the specified port.
- port
- Port to listen on for incoming connections.
- maxConnections
- Maximum number of simultaneous client connections allowed.
Connect
Connects to a remote server.
- host
- Hostname or IP address of the server (e.g., "127.0.0.1" or "example.com").
- port
- Port of the server to connect to.
Disconnect
Disconnects from the current network session (server or client).
Update
Updates the network system.
Currently a stub for Phase 1.1.
- dt
- Time elapsed since last update, in seconds.
staticInstance
Returns a reference to the module instance.
Module has to have been started up first otherwise an exception will be thrown.
staticInstancePtr
Returns a pointer to the module instance.
Module has to have been started up first otherwise an exception will be thrown.
staticShutDown
Shuts down this module and frees any resources it is using.
staticIsStarted
Query if the module has been started.
Protected
Methods
~Module<T>
OnStartUp
Override if you want your module to be notified once it has been constructed and started.
OnShutDown
Override if you want your module to be notified just before it is deleted.
staticInstanceInternal
Returns a singleton instance of this module.