/// <summary>
        /// Fetches information about all existing lobbies
        /// May perform many server calls
        /// </summary>
        public static List <LobbyInfo> GetLobbies()
        {
            var lobbies     = new List <LobbyInfo>();
            var lobbyTuples = Connection.GlobalSpace.QueryAll("existingLobby", typeof(string), typeof(string), typeof(string));

            foreach (var lobbyTuple in lobbyTuples)
            {
                // Setup basic info
                LobbyInfo lobby;
                lobby.Id        = (string)lobbyTuple[1];
                lobby.OwnerName = (string)lobbyTuple[2];
                lobby.Url       = (string)lobbyTuple[3];

                // Connect to lobby space, and fetch players
                // Note: It's super slow to establish this connection everytime
                RemoteSpace lobbySpace = new RemoteSpace(lobby.Url);

                lobby.NumPlayers = 0;
                var playerTuples = lobbySpace.QueryAll("player", typeof(int), typeof(string));
                foreach (var playerTuple in playerTuples)
                {
                    // Check that slot is filled
                    if ((int)playerTuple[1] > 1 && (string)playerTuple[2] != "No user")
                    {
                        lobby.NumPlayers++;
                    }
                }

                lobbies.Add(lobby);
            }

            return(lobbies);
        }
        public static IEnumerable <ITuple> GetSubscribersInALobby(string lobbyUrl)
        {
            RemoteSpace          lobbySpace      = new RemoteSpace(lobbyUrl);
            IEnumerable <ITuple> subscriberTuple = lobbySpace.QueryAll("player", typeof(int), typeof(string));

            return(subscriberTuple);
        }
        public static int GetNumberOfSubscribersInALobby(string lobbyUrl)
        {
            RemoteSpace          lobbySpace      = new RemoteSpace(lobbyUrl);
            IEnumerable <ITuple> subscriberTuple = lobbySpace.QueryAll("player", typeof(int), typeof(string));

            int count = 0;

            foreach (ITuple subscriber in subscriberTuple)
            {
                if ((int)subscriber[1] > 0 && (string)subscriber[2] != "No user")
                {
                    count++;
                }
            }

            return(count);
        }
Пример #4
0
        public void CheckGroupMessage(string groupName)
        {
            while (ContinueToCheckGroupMessage)
            {
                // pegar mensagens
                var tuplas = _remotespace.QueryAll("Group", "Sender", "Message", "Timestamp", "IsWhisper", "Receiver",
                                                   groupName, typeof(string), typeof(string), typeof(string), typeof(bool), typeof(string));

                // mostrar mensagem na GUI
                foreach (var tupla in tuplas)
                {
                    _insertMessage(
                        (string)tupla[6],
                        (string)tupla[7],
                        (string)tupla[8],
                        (string)tupla[9],
                        (bool)tupla[10],
                        (string)tupla[11]
                        );
                }
                Thread.Sleep(100);
            }
        }