mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
WIP
This commit is contained in:
parent
467aa70e3d
commit
f451087d81
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
@ -207,6 +208,8 @@ public void RequestStartMatch()
|
||||
[ClientCallback]
|
||||
public void OnMatchEnded()
|
||||
{
|
||||
Debug.Log($"CanvasController:OnMatchEnded {NetworkClient.active}");
|
||||
|
||||
localPlayerMatch = Guid.Empty;
|
||||
localJoinedMatch = Guid.Empty;
|
||||
ShowLobbyView();
|
||||
@ -236,8 +239,10 @@ internal void OnServerReady(NetworkConnectionToClient conn)
|
||||
}
|
||||
|
||||
[ServerCallback]
|
||||
internal void OnServerDisconnect(NetworkConnectionToClient conn)
|
||||
internal IEnumerator OnServerDisconnect(NetworkConnectionToClient conn)
|
||||
{
|
||||
Debug.Log($"CanvasController:OnServerDisconnect {conn}");
|
||||
|
||||
// Invoke OnPlayerDisconnected on all instances of MatchController
|
||||
OnPlayerDisconnected?.Invoke(conn);
|
||||
|
||||
@ -288,6 +293,8 @@ internal void OnServerDisconnect(NetworkConnectionToClient conn)
|
||||
}
|
||||
|
||||
SendMatchList();
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
}
|
||||
|
||||
[ServerCallback]
|
||||
|
@ -254,6 +254,8 @@ public void CmdRequestExitGame(NetworkConnectionToClient sender = null)
|
||||
|
||||
public void OnPlayerDisconnected(NetworkConnectionToClient conn)
|
||||
{
|
||||
Debug.Log($"MatchController:OnPlayerDisconnected {conn.identity.netId} {player1.netId} {player2.netId}");
|
||||
|
||||
// Check that the disconnecting client is a player in this match
|
||||
if (player1 == conn.identity || player2 == conn.identity)
|
||||
{
|
||||
@ -263,13 +265,19 @@ public void OnPlayerDisconnected(NetworkConnectionToClient conn)
|
||||
|
||||
public IEnumerator ServerEndMatch(NetworkConnectionToClient conn, bool disconnected)
|
||||
{
|
||||
Debug.Log($"MatchController:ServerEndMatch {conn.identity} {disconnected}");
|
||||
|
||||
canvasController.OnPlayerDisconnected -= OnPlayerDisconnected;
|
||||
|
||||
RpcExitGame();
|
||||
|
||||
// Skip a frame so the message goes out ahead of object destruction
|
||||
yield return null;
|
||||
yield return null;
|
||||
yield return null;
|
||||
//yield return new WaitForSeconds(1f);
|
||||
|
||||
Debug.Log($"MatchController:Done Waiting");
|
||||
// Mirror will clean up the disconnecting client so we only need to clean up the other remaining client.
|
||||
// If both players are just returning to the Lobby, we need to remove both connection Players
|
||||
|
||||
@ -306,6 +314,7 @@ public IEnumerator ServerEndMatch(NetworkConnectionToClient conn, bool disconnec
|
||||
[ClientRpc]
|
||||
public void RpcExitGame()
|
||||
{
|
||||
Debug.Log($"MatchController:RpcExitGame");
|
||||
canvasController.OnMatchEnded();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Mirror.Examples.MultipleMatch
|
||||
{
|
||||
@ -43,7 +44,13 @@ public override void OnServerReady(NetworkConnectionToClient conn)
|
||||
/// <param name="conn">Connection from client.</param>
|
||||
public override void OnServerDisconnect(NetworkConnectionToClient conn)
|
||||
{
|
||||
canvasController.OnServerDisconnect(conn);
|
||||
Debug.Log($"OnServerDisconnect {conn}");
|
||||
StartCoroutine(DoServerDisconnect(conn));
|
||||
}
|
||||
|
||||
IEnumerator DoServerDisconnect(NetworkConnectionToClient conn)
|
||||
{
|
||||
yield return canvasController.OnServerDisconnect(conn);
|
||||
base.OnServerDisconnect(conn);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user