private void ReceiveOtherClientStatus(Protocol.BaseProtocol protocol)
    {
        Protocol.StatusProtocol status = protocol as Protocol.StatusProtocol;

        if (status.IsType(Protocol.StatusProtocol.Type.Client))
        {
            if (status.ok)
            {
                currentGamePlayers.Add(nextLobbyId, new Client(status.from_client));
                ++nextLobbyId;
            }
            else
            {
                foreach (KeyValuePair <int, Client> kp in currentGamePlayers)
                {
                    if (kp.Value.nickname == status.from_client)
                    {
                        currentGamePlayers.Remove(kp.Key);
                        PlayerDisconnected?.Invoke(kp.Key);
                        break;
                    }
                }
            }
        }

        GameInfoUpdated?.Invoke();
    }
    private void ReceiveServerStatus(Protocol.BaseProtocol protocol)
    {
        Protocol.StatusProtocol serverStatus = protocol as Protocol.StatusProtocol;

        if (serverStatus.IsType(Protocol.StatusProtocol.Type.Server) && !serverStatus.ok)
        {
            SetConnectionStatus(ConnectionStatus.Error, serverStatus.message);
        }
    }
Example #3
0
    public void ServerError(Protocol.BaseProtocol protocol)
    {
        Protocol.StatusProtocol status = protocol as Protocol.StatusProtocol;

        if (status.IsType(Protocol.StatusProtocol.Type.Server) && !status.ok)
        {
            LoadLevel();
        }
    }