예제 #1
0
 public void Disable()
 {
     if (enabled)
     {
         //Close stream
         enabled     = false;
         clientIndex = -1;
         standardizedTCP.Disable();
         standardizedUDP.Disable();
         tcpClient.Close();
         peerClientInfos.Clear();
         lock (messageLock) clientMessages.Clear();
         gameSession.EndCurrentGame(true);
     }
     else
     {
         gameSession.EndCurrentGame(true);
     }
 }
예제 #2
0
        /// <summary>
        /// Closes the client connections and removes it from lobbies.
        /// </summary>
        /// <param name="faultyConnection">Value representing the state of client connection.</param>
        public void Close(bool faultyConnection, bool lobbyClose)
        {
            if (enabled)
            {
                //Set status
                enabled = false;

                //Remove from lobby
                if (lobby != null)
                {
                    lobby.RemoveClient(this, lobbyClose);
                }

                //Handle connection
                standardizedTCP.Disable();
                standardizedUDP.Disable();

                //Print message
                printMethod.Invoke("Client closed. Faulty Connection: " + faultyConnection + ", Lobby-Close: " + lobbyClose);
            }
        }