Added onClientConnect callback & isClinetConnected bool to NetManager
This commit is contained in:
parent
5f0eeab55e
commit
c7dd950954
@ -42,6 +42,8 @@ namespace MLAPI
|
|||||||
private byte[] messageBuffer;
|
private byte[] messageBuffer;
|
||||||
internal int serverClientId;
|
internal int serverClientId;
|
||||||
|
|
||||||
|
public bool IsClientConnected;
|
||||||
|
public Action OnClientConnectedCallback = null;
|
||||||
|
|
||||||
public NetworkingConfiguration NetworkConfig;
|
public NetworkingConfiguration NetworkConfig;
|
||||||
|
|
||||||
@ -337,6 +339,10 @@ namespace MLAPI
|
|||||||
OnClientDisconnect(clientId);
|
OnClientDisconnect(clientId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IsClientConnected = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (networkError != NetworkError.Ok)
|
else if (networkError != NetworkError.Ok)
|
||||||
{
|
{
|
||||||
@ -379,6 +385,8 @@ namespace MLAPI
|
|||||||
case NetworkEventType.DisconnectEvent:
|
case NetworkEventType.DisconnectEvent:
|
||||||
if (isServer)
|
if (isServer)
|
||||||
OnClientDisconnect(clientId);
|
OnClientDisconnect(clientId);
|
||||||
|
else
|
||||||
|
IsClientConnected = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Only do another iteration if: there are no more messages AND (there is no limit to max events or we have processed less than the maximum)
|
// Only do another iteration if: there are no more messages AND (there is no limit to max events or we have processed less than the maximum)
|
||||||
@ -591,6 +599,9 @@ namespace MLAPI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (OnClientConnectedCallback != null)
|
||||||
|
OnClientConnectedCallback.Invoke();
|
||||||
|
IsClientConnected = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user