private void QuitGame()
 {
     if (_clientInfo.Status == ClientStatus.Host)
     {
         _serverManager.CloseServer();
     }
     if (_clientInfo.Status == ClientStatus.Client)
     {
         _client.Disconnect();
     }
 }
示例#2
0
    public void LeaveLobby()
    {
        if (_clientInfo.Status == ClientStatus.Host)
        {
            _serverManager.CloseServer();
        }

        if (_clientInfo.Status == ClientStatus.Client)
        {
            _client.Disconnect();
        }

        SceneManager.LoadScene("ConnectionMenu");
    }
示例#3
0
 /// <summary>
 /// Fires when application joins a server and gets a Host status confirmation.
 /// Sends PlayerJoined message to the host to request change of scene.
 /// If the host player cannot join the server - the server is closed and no game is initiated.
 /// </summary>
 /// <param name="status"> Status received from the server </param>
 private void JoinedServerAsHost(ushort status)
 {
     if (status == ClientStatus.Host)
     {
         // This message is handled in ConnectionMenuHostMessageReceiver
         // When joining, the Host is treaded exactly as other player with the exception of its LobbyState status.
         // Host's LobbyState status is added in LobbyInitializedHandler to prevent LobbyState from being a ProjectWide class
         _connectionMenuMessageSender.SendPlayerJoinedMessage();
     }
     else
     {
         Debug.Log("Server setup unsuccessful. Try again");
         _serverManager.CloseServer();
     }
     _clientInfo.UnsubscribeOnStatusChanged(JoinedServerAsHost);
 }