/// <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(); }); }
/// <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; jsonResponse = BCService.Friend_GetSummaryDataForProfileId(profileId, i); var pdata = JsonConvert.DeserializeObject <RuyiNetGetSummaryDataForProfileIdResponse>(jsonResponse); if (pdata.status != RuyiNetHttpStatus.OK) { continue; } CurrentPlayers[i] = new RuyiNetProfile() { profileId = pdata.data.playerId, profileName = pdata.data.playerName, pictureUrl = pdata.data.pictureUrl, email = pdata.data.email, }; Logging.Logger.Log($"{pdata.data.playerId} {pdata.data.playerName} {pdata.data.pictureUrl} {pdata.data.email}", Logging.LogLevel.Info); } var response = new RuyiNetResponse() { status = RuyiNetHttpStatus.OK }; return(JsonConvert.SerializeObject(response)); }, (RuyiNetResponse response) => { Initialised = true; onInitialised?.Invoke(); }); }