Skip to content

Commit

Permalink
Move on client stop (#118)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: OnStopClient virtual is replaced by event in Client
  • Loading branch information
uweeby committed Mar 25, 2020
1 parent 27fbcd7 commit 678e386
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
5 changes: 3 additions & 2 deletions Assets/Mirror/Components/NetworkRoomManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public struct PendingPlayer
void Awake()
{
client.Authenticated.AddListener(OnAuthenticated);
client.Disconnected.AddListener(Disconnected);
}

public override void Start()
Expand Down Expand Up @@ -449,9 +450,9 @@ public override void OnClientDisconnect(NetworkConnection conn)
}

/// <summary>
/// This is called when a client is stopped.
/// This is invoked when a client is stopped.
/// </summary>
public override void OnStopClient()
public void Disconnected()
{
OnRoomStopClient();
CallOnClientExitRoom();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public class AdditiveNetworkManager : NetworkManager
[Tooltip("Add all sub-scenes to this list")]
public string[] subScenes;

void Awake()
{
client.Disconnected.AddListener(Disconnected);
}

public override void OnStartServer()
{
base.OnStartServer();
Expand All @@ -35,7 +40,7 @@ public override void OnStopServer()
StartCoroutine(UnloadScenes());
}

public override void OnStopClient()
public void Disconnected()
{
StartCoroutine(UnloadScenes());
}
Expand Down
3 changes: 3 additions & 0 deletions Assets/Mirror/Runtime/NetworkClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class NetworkClient : MonoBehaviour

public NetworkConnectionEvent Connected = new NetworkConnectionEvent();
public NetworkConnectionEvent Authenticated = new NetworkConnectionEvent();
public UnityEvent Disconnected = new UnityEvent();

/// <summary>
/// The NetworkConnection object this client is using.
Expand Down Expand Up @@ -529,6 +530,8 @@ internal void HandleClientDisconnect(NetworkConnection conn)
ready = false;
connection = null;
}

Disconnected.Invoke();
}

/// <summary>
Expand Down
7 changes: 0 additions & 7 deletions Assets/Mirror/Runtime/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,6 @@ public void StopServer()
/// </summary>
public void StopClient()
{
OnStopClient();

if (LogFilter.Debug) Debug.Log("NetworkManager StopClient");
isNetworkActive = false;

Expand Down Expand Up @@ -1274,11 +1272,6 @@ public virtual void OnClientSceneChanged(NetworkConnectionToServer conn)
/// </summary>
public virtual void OnStopServer() { }

/// <summary>
/// This is called when a client is stopped.
/// </summary>
public virtual void OnStopClient() { }

/// <summary>
/// This is called when a host is stopped.
/// </summary>
Expand Down

0 comments on commit 678e386

Please sign in to comment.