Esempio n. 1
0
        /// <summary>
        /// Searches for lobbies created by other players.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="numResults">The maximum number of lobbies to return.</param>
        /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
        /// <param name="freeSlots">The number of free slots needed.</param>
        /// <param name="searchCriteria">JSON string representing parameters to search for.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void FindLobbies(int index, int numResults, RuyiNetLobbyType lobbyType,
                                int freeSlots, string searchCriteria, Action <RuyiNetLobby[]> callback)
        {
            var payload = new RuyiNetLobbyFindRequest()
            {
                appId          = mClient.AppId,
                numResults     = numResults,
                freeSlots      = freeSlots,
                ranked         = (lobbyType == RuyiNetLobbyType.RANKED),
                searchCriteria = searchCriteria
            };

            RunPlatformScript(index, "Lobby_Find", JsonConvert.SerializeObject(payload),
                              (RuyiNetLobbyFindResponse response) =>
            {
                var results = response.data.response.results;
                var lobbies = new RuyiNetLobby[results.count];
                for (int i = 0; i < results.count; ++i)
                {
                    lobbies[i] = new RuyiNetLobby(results.items[i]);
                }

                callback(lobbies);
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a lobby that other players can find and join.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="maxSlots">The maximum number of players that can join this lobby.</param>
        /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
        /// <param name="customAttributes">JSON string of custom attributes to attach to this lobby.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void CreateLobby(int index, int maxSlots, RuyiNetLobbyType lobbyType,
                                string customAttributes, Action <RuyiNetLobby> callback)
        {
            var payload = new RuyiNetLobbyCreateRequest()
            {
                appId            = mClient.AppId,
                maxSlots         = maxSlots,
                ranked           = (lobbyType == RuyiNetLobbyType.RANKED),
                customAttributes = customAttributes
            };

            RunPlatformScript(index, "Lobby_Create", JsonConvert.SerializeObject(payload),
                              (RuyiNetLobbyResponse response) =>
            {
                mCurrentLobby = response;
                callback(mCurrentLobby);
                PollLobbyStatus();
            });
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a lobby that other players can find and join.
        /// </summary>
        /// <param name="clientIndex">The index of user</param>
        /// <param name="maxSlots">The maximum number of players that can join this lobby.</param>
        /// <param name="isOpen">Whether or not the lobby is open by default.</param>
        /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
        /// <param name="jsonAttributes">JSON string of custom attributes to attach to this lobby.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void CreateLobby(int clientIndex, int maxSlots, RuyiNetLobbyType lobbyType, bool isOpen, string jsonAttributes, Action <RuyiNetLobby> callback)
        {
            EnqueueTask(() =>
            {
                try
                {
                    return(mClient.BCService.Lobby_CreateLobby((BrainCloudApi.LobbyType)lobbyType, maxSlots, isOpen, jsonAttributes, clientIndex));
                }
                catch (Exception e)
                {
                    Logging.Logger.Log("", Logging.LogLevel.Error);
                    var response = new RuyiNetResponse()
                    {
                        status  = 999,
                        message = e.ToString()
                    };

                    return(JsonConvert.SerializeObject(response));
                }
            }, (RuyiNetLobbyResponse response) => OnLobbyResponse(callback, response));
        }
Esempio n. 4
0
        /// <summary>
        /// Searches for lobbies created by other players.
        /// </summary>
        /// <param name="clientIndex">The index of user</param>
        /// <param name="numResults">The maximum number of lobbies to return.</param>
        /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
        /// <param name="freeSlots">The number of free slots needed.</param>
        /// <param name="jsonAttributes">JSON string representing parameters to search for.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void FindLobbies(int clientIndex, int numResults, RuyiNetLobbyType lobbyType, int freeSlots, string jsonAttributes, Action <RuyiNetLobby[]> callback)
        {
            EnqueueTask(() =>
            {
                try
                {
                    return(mClient.BCService.Lobby_FindLobbies(freeSlots, numResults, jsonAttributes, clientIndex));;
                }
                catch (Exception e)
                {
                    Logging.Logger.Log("", Logging.LogLevel.Error);
                    var response = new RuyiNetResponse()
                    {
                        status  = 999,
                        message = e.ToString()
                    };

                    return(JsonConvert.SerializeObject(response));
                }
            }, (RuyiNetLobbyFindResponse response) => OnLobbyFindResponse(callback, response));
        }
Esempio n. 5
0
 /// <summary>
 /// Searches for lobbies created by other players.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="numResults">The maximum number of lobbies to return.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 /// <param name="freeSlots">The number of free slots needed.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void FindLobbies(int index, int numResults, RuyiNetLobbyType lobbyType,
                         int freeSlots, Action <RuyiNetLobby[]> callback)
 {
     FindLobbies(index, numResults, lobbyType, freeSlots, "{}", callback);
 }
Esempio n. 6
0
 /// <summary>
 /// Searches for lobbies created by other players.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="numResults">The maximum number of lobbies to return.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void FindLobbies(int index, int numResults, RuyiNetLobbyType lobbyType,
                         Action <RuyiNetLobby[]> callback)
 {
     FindLobbies(index, numResults, lobbyType, 0, callback);
 }
Esempio n. 7
0
 /// <summary>
 /// Creates a lobby that other players can find and join.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="maxSlots">The maximum number of players that can join this lobby.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void CreateLobby(int index, int maxSlots, RuyiNetLobbyType lobbyType, Action <RuyiNetLobby> callback)
 {
     CreateLobby(index, maxSlots, lobbyType, "{}", callback);
 }
Esempio n. 8
0
 /// <summary>
 /// Creates a lobby that other players can find and join.
 /// </summary>
 /// <param name="clientIndex">The index of user</param>
 /// <param name="maxSlots">The maximum number of players that can join this lobby.</param>
 /// <param name="isOpen">Whether or not the lobby is open by default.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void CreateLobby(int clientIndex, int maxSlots, RuyiNetLobbyType lobbyType, bool isOpen, Action <RuyiNetLobby> callback)
 {
     CreateLobby(clientIndex, maxSlots, lobbyType, isOpen, "{}", callback);
 }
Esempio n. 9
0
 /// <summary>
 /// Creates a lobby that other players can find and join.
 /// </summary>
 /// <param name="clientIndex">The index of user</param>
 /// <param name="maxSlots">The maximum number of players that can join this lobby.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 /// <param name="jsonAttributes">JSON string of custom attributes to attach to this lobby.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void CreateLobby(int clientIndex, int maxSlots, RuyiNetLobbyType lobbyType, string jsonAttributes, Action <RuyiNetLobby> callback)
 {
     CreateLobby(clientIndex, maxSlots, lobbyType, true, jsonAttributes, callback);
 }
Esempio n. 10
0
        /// <summary>
        /// Creates a lobby that other players can find and join.
        /// </summary>
        /// <param name="clientIndex">The index of user</param>
        /// <param name="maxSlots">The maximum number of players that can join this lobby.</param>
        /// <param name="isOpen">Whether or not the lobby is open by default.</param>
        /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
        /// <param name="jsonAttributes">JSON string of custom attributes to attach to this lobby.</param>
        public async Task <RuyiNetLobbyResponse> CreateLobby(int clientIndex, int maxSlots, RuyiNetLobbyType lobbyType, bool isOpen, string jsonAttributes)
        {
            var resp = await mClient.BCService.Lobby_CreateLobbyAsync((BrainCloudApi.LobbyType) lobbyType, maxSlots, isOpen, jsonAttributes, clientIndex, token);

            return(mClient.Process <RuyiNetLobbyResponse>(resp));
        }
Esempio n. 11
0
 /// <summary>
 /// Creates a lobby that other players can find and join.
 /// </summary>
 /// <param name="clientIndex">The index of user</param>
 /// <param name="maxSlots">The maximum number of players that can join this lobby.</param>
 /// <param name="isOpen">Whether or not the lobby is open by default.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 public Task <RuyiNetLobbyResponse> CreateLobby(int clientIndex, int maxSlots, RuyiNetLobbyType lobbyType, bool isOpen)
 {
     return(CreateLobby(clientIndex, maxSlots, lobbyType, isOpen, "{}"));
 }
Esempio n. 12
0
 /// <summary>
 /// Creates a lobby that other players can find and join.
 /// </summary>
 /// <param name="clientIndex">The index of user</param>
 /// <param name="maxSlots">The maximum number of players that can join this lobby.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 /// <param name="jsonAttributes">JSON string of custom attributes to attach to this lobby.</param>
 public Task <RuyiNetLobbyResponse> CreateLobby(int clientIndex, int maxSlots, RuyiNetLobbyType lobbyType, string jsonAttributes)
 {
     return(CreateLobby(clientIndex, maxSlots, lobbyType, true, jsonAttributes));
 }
Esempio n. 13
0
        /// <summary>
        /// Searches for lobbies created by other players.
        /// </summary>
        /// <param name="clientIndex">The index of user</param>
        /// <param name="numResults">The maximum number of lobbies to return.</param>
        /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
        /// <param name="freeSlots">The number of free slots needed.</param>
        /// <param name="jsonAttributes">JSON string representing parameters to search for.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public async Task <RuyiNetLobbyFindResponse> FindLobbies(int clientIndex, int numResults, RuyiNetLobbyType lobbyType, int freeSlots, string jsonAttributes)
        {
            var resp = await mClient.BCService.Lobby_FindLobbiesAsync(freeSlots, numResults, jsonAttributes, clientIndex, token);

            return(mClient.Process <RuyiNetLobbyFindResponse>(resp));
        }
Esempio n. 14
0
 /// <summary>
 /// Searches for lobbies created by other players.
 /// </summary>
 /// <param name="clientIndex">The index of user</param>
 /// <param name="numResults">The maximum number of lobbies to return.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 /// <param name="freeSlots">The number of free slots needed.</param>
 public Task <RuyiNetLobbyFindResponse> FindLobbies(int clientIndex, int numResults, RuyiNetLobbyType lobbyType, int freeSlots)
 {
     return(FindLobbies(clientIndex, numResults, lobbyType, freeSlots, "{}"));
 }
Esempio n. 15
0
 /// <summary>
 /// Searches for lobbies created by other players.
 /// </summary>
 /// <param name="clientIndex">The index of user</param>
 /// <param name="numResults">The maximum number of lobbies to return.</param>
 /// <param name="lobbyType">Whether or not this lobby is for a RANKED MATCH or a PLAYER MATCH.</param>
 public Task <RuyiNetLobbyFindResponse> FindLobbies(int clientIndex, int numResults, RuyiNetLobbyType lobbyType,
                                                    Action <RuyiNetLobby[]> callback)
 {
     return(FindLobbies(clientIndex, numResults, lobbyType, 0));
 }