コード例 #1
0
    void OnConnectionRemoved(INetworkInterfaceConnection oldConnection)
    {
        Log.Info("[PlayerRepertoireServer] OnConnectionRemoved: " + oldConnection.Id);
        _newConnectionsNotYetPlayers.Remove(oldConnection);

        int playerIndex = _playerConnections.IndexOf(oldConnection);

        if (playerIndex == -1)
        {
            // The connection was not yet a valid player. Nothing else to do
            return;
        }

        PlayerId playerId = _players[playerIndex].PlayerId;

        // destroy
        DestroyPlayer(playerId);

        // remove connection
        _playerConnections.RemoveAt(playerIndex);


        // Notify other players
        NetMessagePlayerLeft playerLeftMessage = new NetMessagePlayerLeft()
        {
            playerId = playerId
        };

        _serverSession.SendNetMessage(playerLeftMessage, _playerConnections);
        Log.Info("[PlayerRepertoireServer] sent NetMessagePlayerLeft");
    }
コード例 #2
0
 void OnMsg_NetMessagePlayerLeft(NetMessagePlayerLeft message, INetworkInterfaceConnection source)
 {
     if (SystemReady)
     {
         Log.Info("[PlayerRepertoireClient] OnMsg_NetMessagePlayerLeft");
         _players.RemoveFirst((p) => p.PlayerId == message.playerId);
     }
     else
     {
         Log.Info("[PlayerRepertoireClient] *Deferring* OnMsg_NetMessagePlayerLeft");
         _deferredNetMessages.Enqueue(message);
     }
 }