public async Task Login(string username, string password) { CurrentLoginStatus = LoginStatus.LOGGING_IN; BLEDebug.LogInfo("Logging In"); FlatJSON fJSON = new FlatJSON(); fJSON.Add("username", username); fJSON.Add("password", password); HttpContent req = fJSON.SerializeContent(); var result = await client.PostAsync("https://echelon.3pointlabs.org/auth/login", req); string body = await result.Content.ReadAsStringAsync(); BLEDebug.LogInfo("Auth " + body); fJSON.Deserialize(body); fJSON.TryGetStringValue("username", out _PlayerId); fJSON.TryGetStringValue("idToken", out idToken); fJSON.TryGetStringValue("refreshToken", out refreshToken); fJSON.TryGetStringValue("accessToken", out accessToken); if (idToken != null) { // Set Token for Authentication client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(idToken); CurrentLoginStatus = LoginStatus.LOGGED_IN; } else { CurrentLoginStatus = LoginStatus.FAILED; } }
public void UpdateCustomization(string characterModelId) { BLEDebug.LogInfo("Sending Customization Update"); FlatJSON fJSON = new FlatJSON(); fJSON.Add("PlayerId", PlayerId); fJSON.Add("characterModelId", characterModelId); Client.SendMessage(Client.NewMessage(OP_CODE_CUSTOMIZATION_UPDATE) .WithDeliveryIntent(DeliveryIntent.Reliable) .WithTargetPlayer(Constants.PLAYER_ID_SERVER) .WithPayload(StringToBytes(fJSON.ToString()))); }
public void UpdateStats(int rotations, int rpm, float[] playerPosition, float progressDistance) { BLEDebug.LogInfo("Sending Stats Update"); FlatJSON fJSON = new FlatJSON(); fJSON.Add("rotations", rotations); fJSON.Add("rpm", rpm); fJSON.Add("playerPosition", playerPosition); fJSON.Add("progressDistance", progressDistance); Client.SendMessage(Client.NewMessage(OP_CODE_STATS_UPDATE) .WithDeliveryIntent(DeliveryIntent.Reliable) .WithTargetPlayer(Constants.PLAYER_ID_SERVER) .WithPayload(StringToBytes(fJSON.ToString()))); }
public async Task CheckMatchmakingTicketStatus() { BLEDebug.LogInfo("Checking MatchMaking Ticket Status"); FlatJSON fJSON = new FlatJSON(); fJSON.Add("TicketId", TicketId); HttpContent req = fJSON.SerializeContent(); HttpResponseMessage result = await client.PostAsync("https://echelon.3pointlabs.org/matchmaking/status", req); string body = await result.Content.ReadAsStringAsync(); BLEDebug.LogInfo("Ticket " + body); fJSON.Deserialize(body); fJSON.TryGetStringValue("Status", out _Status); if (Status == "COMPLETED") { fJSON.TryGetStringValue("GameSessionArn", out _GameSessionArn); fJSON.TryGetStringValue("IpAddress", out _IpAddress); fJSON.TryGetStringValue("DnsName", out _DnsName); fJSON.TryGetIntValue("Port", out _TcpPort); fJSON.TryGetStringValue("PlayerSessionId", out _PlayerSessionId); FindAvailableUDPPort(); } }
public async Task SetCustomization(string cModelId) { _CharacterModelId = cModelId; BLEDebug.LogInfo("Setting CharacterModelId"); FlatJSON fJSON = new FlatJSON(); fJSON.Add("characterModelId", _CharacterModelId); HttpContent req = fJSON.SerializeContent(); HttpResponseMessage result = await client.PutAsync("https://echelon.3pointlabs.org/profile/customization", req); string body = await result.Content.ReadAsStringAsync(); BLEDebug.LogInfo("CharacterModel " + body); fJSON.Deserialize(body); // fJSON.TryGetStringValue("characterModelId", out _CharacterModelId); }