Пример #1
0
        /// <summary>
        /// Get the profile of the specified user.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="profileId">The profile ID of the user to get the profile for.</param>
        public async Task <RuyiNetGetProfileResponse> GetProfile(int index, string profileId)
        {
            var payload = new RuyiNetProfileIdRequest()
            {
                profileId = profileId
            };
            var resp = await mClient.BCService.Script_RunParentScriptAsync("GetProfile", JsonConvert.SerializeObject(payload), "RUYI", index, token);

            return(mClient.Process <RuyiNetGetProfileResponse>(resp));
        }
Пример #2
0
 public void GetProfile(int index, string profileId, RuyiNetTask <RuyiNetGetProfileResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         var payload = new RuyiNetProfileIdRequest()
         {
             profileId = profileId
         };
         return(mClient.BCService.Script_RunParentScript("GetProfile", JsonConvert.SerializeObject(payload), "RUYI", index));
     }, callback);
 }
Пример #3
0
 /// <summary>
 /// Removes a user from the player's friend list.
 /// </summary>
 /// <param name="index">The index of user</param>
 /// <param name="profileId">The profile ID of the user to remove.</param>
 /// <param name="callback">The function to call when the task completes.</param>
 public void RemoveFriend(int index, string profileId, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
 {
     EnqueueTask(() =>
     {
         var payload = new RuyiNetProfileIdRequest()
         {
             profileId = profileId
         };
         return(mClient.BCService.Script_RunParentScriptAsync("RemoveFriend", JsonConvert.SerializeObject(payload), "RUYI", index, token).Result);
     }, callback);
 }
Пример #4
0
        /// <summary>
        /// Invite someone to join a party.
        /// </summary>
        /// <param name="index">The index of user</param>
        /// <param name="profileId">The profile ID of the player to invite.</param>
        /// <param name="callback">The function to call when the task completes.</param>
        public void SendPartyInvitation(int index, string profileId, RuyiNetTask <RuyiNetResponse> .CallbackType callback)
        {
            EnqueueTask(() =>
            {
                var payload = new RuyiNetProfileIdRequest()
                {
                    profileId = profileId
                };

                var response = mClient.BCService.Script_RunParentScriptAsync("SendPartyInvitation", JsonConvert.SerializeObject(payload), "RUYI", index, token).Result;
                return(response);
            }, callback);
        }
Пример #5
0
        /// <summary>
        /// Initialise the RUYI net client and switch to the game context.
        /// </summary>
        /// <param name="appId">The App ID of the game to initialise for.</param>
        /// <param name="appSecret">The App secret of the game. NOTE: This is a password and should be treated as such.</param>
        /// <param name="onInitialised">The function to call whe initialisation completes.</param>
        public void Initialise(string appId, string appSecret, Action onInitialised)
        {
            if (Initialised)
            {
                onInitialised?.Invoke();

                return;
            }

            AppId     = appId;
            AppSecret = appSecret;

            EnqueueTask(() =>
            {
                var hostString = Dns.GetHostName();

                IPHostEntry hostInfo = Dns.GetHostEntry(hostString);
                foreach (IPAddress ip in hostInfo.AddressList)
                {
                    if (ip.AddressFamily == AddressFamily.InterNetwork)
                    {
                        RemoteIpAddress = ip.ToString();
                    }
                }

                for (int i = 0; i < MAX_PLAYERS; ++i)
                {
                    CurrentPlayers[i] = null;
                    var jsonResponse  = BCService.Identity_SwitchToSingletonChildProfile(AppId, true, i);
                    var childProfile  = JsonConvert.DeserializeObject <RuyiNetSwitchToChildProfileResponse>(jsonResponse);
                    if (childProfile.status != RuyiNetHttpStatus.OK)
                    {
                        continue;
                    }

                    var profileId   = childProfile.data.parentProfileId;
                    var profileName = childProfile.data.playerName;

                    NewUser = childProfile.data.newUser;

                    var payload = new RuyiNetProfileIdRequest()
                    {
                        profileId = profileId
                    };
                    jsonResponse = BCService.Script_RunParentScript("GetProfile", JsonConvert.SerializeObject(payload), "RUYI", i);

                    var profileData = JsonConvert.DeserializeObject <RuyiNetGetProfileResponse>(jsonResponse);
                    if (profileData.status != RuyiNetHttpStatus.OK ||
                        profileData.data.success == false)
                    {
                        continue;
                    }

                    CurrentPlayers[i] = profileData.data.response;
                }

                var response = new RuyiNetResponse()
                {
                    status = RuyiNetHttpStatus.OK
                };

                return(JsonConvert.SerializeObject(response));
            }, (RuyiNetResponse response) =>
            {
                Initialised = true;

                onInitialised?.Invoke();
            });
        }