private static async Task QueryData(HydraClient client) { //GetGameConfigResponse gameConfig = await client.GetGameConfig(new GetGameConfigRequest //{ // structureVersion = structureVersion //}); //GetGameConfigLayersResponse gameConfigLayers = await client.GetGameConfigLayers(new GetGameConfigLayersRequest() //{ // layers = gameConfig.data //}); //await client.LoginMessaging(new LoginMessagingRequest()); //await client.SendExternalSessionToken(new SendExternalSessionTokenRequest { externalSessionToken = tokens.data.ProviderToken }); //GetChallengesResponse challenges = await client.ChallengesGetAll(new ChallengesGetAllRequest()); //GetUserInventoryResponse userInventory = await client.GetUserInventory(new GetUserInventoryRequest()); //GetUsersResponse users = await client.GetUsers(new GetUsersRequest //{ // users = new[] // { // new User // { // Uid = new Guid().ToString("D") // } // } //}); GetDataCenterOccupationStatsResponse occupation = await client.GetDataCenterOccupationStats(new GetDataCenterOccupationStatsRequest { generation = 1, state = 1 }); Console.WriteLine($"UsersOnline: {occupation.data.UsersOnline}"); }
private static async Task <HydraClient> Login(string gameCode) { var hydraConfig = new HydraConfig(); var rateLimiter = new RateLimiter(); var client = new HydraClient(hydraConfig, rateLimiter); hydraConfig.UpdateServiceEndpoint( HydraServices.SharedService, new Endpoint { Name = HydraServices.SharedService, IP = "obt-shared-eds.qcapi.net", // TODO: load URL somewhere Port = 11701, Protocol = 1 }); Console.WriteLine("Getting environments"); var environments = await client.GetEnvironmentList(new GetEnvironmentListRequest { versions = hydraConfig.GetServiceVersions() }); hydraConfig.UpdateServiceEndpoint(HydraServices.AuthService2, environments?.data?.Environments.First()?.Endpoint); Console.WriteLine("Entering queue"); const string structureVersion = "12.31"; var loginResponse = await client.Login(new LoginRequest { login = gameCode, password = "", provider = "bnet", signature = new LoginSignature { Id = Guid.NewGuid().ToString("D") }, structureVersion = structureVersion, clientData = new LoginClientData { BuildConfiguration = "RetailClient", BuildVersion = "0.1.2589268", ProductBranch = "", Location = "", RequestedProfession = 0, LauncherType = "BETHESDA_NET" } }); int position = -1; while (loginResponse.data.Token.State != 2) { if (loginResponse.data.Position != position) { position = loginResponse.data.Position; Console.WriteLine($"Queued at position {position}"); } loginResponse = await client.CheckLogin(new CheckLoginRequest { token = loginResponse.data.Token.Token }); } var tokens = await client.GetTokens(new GetTokensRequest { token = loginResponse.data.Token.Token, versions = hydraConfig.GetServiceVersions() }); client.UpdateAuthorizationToken(tokens.data.AuthorizationToken); client.UpdateAccessRoleToken(tokens.data.AccessRoleToken); foreach (var endpoint in tokens.data.Endpoints) { hydraConfig.UpdateServiceEndpoint(endpoint); } string authorizationToken = tokens.data.AuthorizationToken; string diagnosticToken = tokens.data.DiagnosticToken; var refreshTokensResponse = await client.RefreshTokens(new RefreshTokensRequest { tokens = new[] { authorizationToken, diagnosticToken } }); authorizationToken = refreshTokensResponse.data.Tokens .Where(t => t.OldValue == authorizationToken) .Select(t => t.NewValue) .FirstOrDefault(); //diagnosticToken = refreshTokensResponse.data.Tokens // .Where(t => t.OldValue == diagnosticToken) // .Select(t => t.NewValue) // .FirstOrDefault(); client.UpdateAuthorizationToken(authorizationToken); Console.WriteLine("Logged in"); return(client); }