EMI_NetworkManager Callbacks
The following is a list of avaiable delegates you can tie into to create an event based architecture.
Available Callbacks
| Name | Delegate Type | Description |
|---|---|---|
| OnClientStarted | void | Invoked when the local client has been started. |
| OnClientStopped | void | Invoked when the local client has been stopped. |
| OnClientConnected | void | Invoked when the local client has successfully connected to the server. |
| OnClientDisconnected | void | Invoked when the local client has disconnected from the server for any reason. |
| OnServerStarted | void | Invoked when the local server has started. |
| OnServerStopped | void | Invoked when the local server has stopped. |
| OnServerAddedPlayer | NetworkConnection | Invoked when the local server has received a spawn player request from the client. |
| OnClientMarkedReady | NetworkConnection | Invoked when the local server has received a message from the client indicating they're marked as "ready" |
Example Tie In
The following is the proper way to register and deregister functions with these available delegates:
protected virtual void OnEnable()
{
EMI_NetworkManager.instance.OnClientStarted += MyClientStarted;
EMI_NetworkManager.instance.OnServerAddedPlayer += ServerReceivedClientReady;
}
protected virtual void OnDisable()
{
EMI_NetworkManager.instance.OnClientStarted -= MyClientStarted;
EMI_NetworkManager.instance.OnServerAddedPlayer -= ServerReceivedClientReady;
}
public virtual void MyClientStarted()
{
...
}
public virtual void ServerReceivedClientReady(NetworkConnection conn)
{
...
}