/// <summary> /// This Async service For Get the Player's Info. /// </summary> /// <exception cref="GameballException">Thrown if the request fails..</exception> public async Task <PlayerInfo> GetPlayerInfoAsync(string playerUniqueId, GameballLang Language = 0) { if (Language != 0) { Client.DefaultRequestHeaders.Add("lang", GameballUtils.ToValidLang(Language)); } PlayerInfoRequest Info = new PlayerInfoRequest() { PlayerUniqueId = playerUniqueId, Hash = GameballUtils.GetSHA1(playerUniqueId, TransactionKey) }; Info.Validate(); var response = await this.Client.PostAsync(ApiBase + GameballConstants.PlayerInfo, new StringContent(Info.Serialize(), Encoding.UTF8, "application/json")); //Removes Overhead of lang header if not necessary in next calls. Client.DefaultRequestHeaders.Remove("lang"); if (!response.IsSuccessStatusCode) { throw (BuildGameballException(response)); } else { return(JsonConvert.DeserializeObject <PlayerInfo>(await response.Content.ReadAsStringAsync())); } }
private void OnOpponentNameRecieved(PlayerInfoRequest request) { opponentName = request.playerName; if (server != null) { chessControl.Init(ChessControl.Mode.Server, playerName, opponentName, size, comboLength, scoreToWin); ChatManager.instance.SetServer(server, playerName); } else { chessControl.Init(ChessControl.Mode.Client, playerName, opponentName); ChatManager.instance.SetClient(client, playerName); } serverWaitMessage.SetActive(false); clientWaitMessage.SetActive(false); }