private void GetFriendsResult(ApiRequest.ApiResponse response, GetFriendsResultDelegate resultDelegate) { bool result = response.IsSuccess; string reason = ""; List<CharacterFriend> friends = null; if (result) { try { friends = response.ResponseObject["friends"].ToObject<List<CharacterFriend>>(); } catch (Exception e) { friends = null; reason = e.Message; } } else { reason = response.StatusText; } if (resultDelegate != null) resultDelegate(friends, reason); }
public void GetFriendsAsync(GetFriendsResultDelegate resultDelegate) { if (IsActive == false) return; ApiRequest apiReq = new ApiRequest(_settings.AuthorizationTokenId, _settings.AuthorizationToken) { RequestBody = "{}" }; Task.Run(async () => { ApiRequest.ApiResponse apiResp = await apiReq.StartRequestAsync("character/friends/get"); GetFriendsResult(apiResp, resultDelegate); }); }