The NetworkServerSimple is a basic server class without the "game" related functionality that the NetworkServer class has.
This class has no scene management, spawning, player objects, observers, or static interface like the NetworkServer class. It is simply a server that listens on a port, manages connections, and handles messages. There can be more than one instance of this class in a process.
Like the NetworkServer and NetworkClient classes, it allows the type of NetworkConnection class created for new connections to be specified with SetNetworkConnectionClass(), so custom types of network connections can be used with it.
This class can be used by overriding the virtual functions OnConnected, OnDisconnected and OnData; or by registering message handlers.
connections | A read-only list of the current connections being managed. |
handlers | The message handler functions that are registered. |
hostTopology | The transport layer host-topology that the server is configured with. |
listenPort | The network port that the server is listening on. |
messageBuffer | The internal buffer that the server reads data from the network into. This will contain the most recent data read from the network when OnData() is called. |
messageReader | A NetworkReader object that is bound to the server's messageBuffer. |
networkConnectionClass | The type of class to be created for new network connections from clients. |
serverHostId | The transport layer hostId of the server. |
useWebSockets | This causes the server to listen for WebSocket connections instead of regular transport layer connections. |
ClearHandlers | Clears the message handlers that are registered. |
Configure | This configures the network transport layer of the server. |
Disconnect | This disconnects the connection of the corresponding connection id. |
DisconnectAllConnections | This disconnects all of the active connections. |
FindConnection | This looks up the network connection object for the specified connection Id. |
Initialize | Initialization function that is invoked when the server starts listening. This can be overridden to perform custom initialization such as setting the NetworkConnectionClass. |
Listen | This starts the server listening for connections on the specified port. |
ListenRelay | Starts a server using a Relay server. This is the manual way of using the Relay server, as the regular NetworkServer.Connect() will automatically use the Relay server if a match exists. |
OnConnected | This virtual function can be overridden to perform custom functionality for new network connections. |
OnConnectError | A virtual function that is invoked when there is a connection error. |
OnData | This virtual function can be overridden to perform custom functionality when data is received for a connection. |
OnDataError | A virtual function that is called when a data error occurs on a connection. |
OnDisconnected | This virtual function can be overridden to perform custom functionality for disconnected network connections. |
OnDisconnectError | A virtual function that is called when a disconnect error happens. |
RegisterHandler | This registers a handler function for a message Id. |
RemoveConnectionAtIndex | This removes a connection object from the server's list of connections. |
SendBytesTo | This sends the data in an array of bytes to the connected client. |
SendWriterTo | This sends the contents of a NetworkWriter object to the connected client. |
SetConnectionAtIndex | This adds a connection created by external code to the server's list of connections, at the connection's connectionId index. |
SetNetworkConnectionClass | This sets the class that is used when creating new network connections. |
Stop | This stops a server from listening. |
UnregisterHandler | This unregisters a registered message handler function. |
Update | This function pumps the server causing incoming network data to be processed, and pending outgoing data to be sent. |
UpdateConnections | This function causes pending outgoing data on connections to be sent, but unlike Update() it works when the server is not listening. |