void OnApplicationQuit()
    {
        if (isHost && matchInfo != null)
        {
            // If the match is not destroyed, the room will stay visible for 20-30 seconds, confusing new clients

            // This method is not reliable, as the application quits before DestroyMatch is able to finish
            networkMatcher.DestroyMatch(matchInfo.networkId, 0, OnDestroyMatch);
            PrintLogger.printLog("NetworkManager: Application quit with client as host; destroying room");
        }
        networkMatcher.DropConnection(matchInfo.networkId, matchInfo.nodeId, 0, OnDropConnection);

        GameManagerScript.instance.isActivePlayer = false;
        GameManagerScript.instance.registerPlayers();
    }
Esempio n. 2
0
 public void Disconnect()
 {
     if (reqMaster)
     {
         if (matchInfo != null)
         {
             match.DestroyMatch(matchInfo.networkId, reqDomain, OnMatchDestroy);
             matchInfo = null;
         }
     }
     else
     {
         if (client != null)
         {
             client.Shutdown();
             client = null;
         }
     }
 }