Skip to content

Commit

Permalink
fix: invoking started event when Listening is false (#675)
Browse files Browse the repository at this point in the history
when Listening is false the transport will never call the TransportStarted function so NetworkServer will never set Active or call Started.
  • Loading branch information
James-Frowen committed Mar 8, 2021
1 parent 84830b9 commit afef2d4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Assets/Mirage/Runtime/NetworkServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ public async UniTask ListenAsync()
Transport.Connected.AddListener(TransportConnected);
await Transport.ListenAsync();
}
else
{
// if not listening then call started events right away
NotListeningStarted();
}
}
catch (Exception ex)
{
Expand All @@ -217,6 +222,14 @@ public async UniTask ListenAsync()
}
}

private void NotListeningStarted()
{
logger.Log("Server started but not Listening");
Active = true;
// (useful for loading & spawning stuff from database etc.)
Started?.Invoke();
}

private void TransportStarted()
{
logger.Log("Server started listening");
Expand Down

0 comments on commit afef2d4

Please sign in to comment.