mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-17 05:18:27 +00:00
add event for when server changes status
This commit is contained in:
parent
efab1b9e3e
commit
309c00b72d
1 changed files with 10 additions and 3 deletions
|
@ -32,6 +32,9 @@ namespace SanAndreasUnity.Net
|
|||
NetworkClientStatus m_lastClientStatus = NetworkClientStatus.Disconnected;
|
||||
public event System.Action onClientStatusChanged = delegate {};
|
||||
|
||||
private NetworkServerStatus m_lastServerStatus = NetworkServerStatus.Stopped;
|
||||
public event System.Action onServerStatusChanged = delegate {};
|
||||
|
||||
public static int NumSpawnedNetworkObjects => NetworkIdentity.spawned.Count;
|
||||
|
||||
|
||||
|
@ -54,15 +57,19 @@ namespace SanAndreasUnity.Net
|
|||
{
|
||||
|
||||
NetworkClientStatus clientStatusNow = NetStatus.clientStatus;
|
||||
|
||||
if (clientStatusNow != m_lastClientStatus)
|
||||
{
|
||||
m_lastClientStatus = clientStatusNow;
|
||||
|
||||
// notify
|
||||
F.InvokeEventExceptionSafe(this.onClientStatusChanged);
|
||||
}
|
||||
|
||||
NetworkServerStatus serverStatusNow = NetStatus.serverStatus;
|
||||
if (serverStatusNow != m_lastServerStatus)
|
||||
{
|
||||
m_lastServerStatus = serverStatusNow;
|
||||
F.InvokeEventExceptionSafe(this.onServerStatusChanged);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue