Example #1
0
        private void onPlayerDisconnected(ServerPlayerModel serverPlayerModel)
        {
            Log.Info(serverPlayerModel.PlayerID + " ZoneController.onPlayerDisconnected");
            removePlayerReferences(serverPlayerModel);

            // Only notify other players of disconnection if game isn't over
            if (!ZoneModel.IsCompleted)
            {
                SendPlayerDisconnectedEventSCMD.Execute(serverPlayerModel.PlayerID, AllPlayersinZone);
            }
        }
        private void onClientDisconnected(IClientConnection clientConnection)
        {
            clientConnection.Disconnected -= onClientDisconnected;
            string disconnectedPlayerID = clientPeerConnectionToPlayerID[clientConnection];

            for (int i = activeServerPlayerModels.Count - 1; i >= 0; i--)
            {
                if (activeServerPlayerModels[i].PlayerID == disconnectedPlayerID)
                {
                    activeServerPlayerModels.RemoveAt(i);
                }
                else
                {
                    // unready all players
                    SendPlayerUnreadyEventSCMD.Execute(activeServerPlayerModels[i].ClientConnection, activeServerPlayerModels);
                }
            }

            playerIDToConnection.Remove(disconnectedPlayerID);
            clientPeerConnectionToPlayerID.Remove(clientConnection);

            SendPlayerDisconnectedEventSCMD.Execute(disconnectedPlayerID, activeServerPlayerModels);
        }