异步请求(.NET)
描述
服务器端集成的一个好处是,通过使用并行性,可以利用服务器端提供的巨大带宽和计算资源。 Target .NET SDK支持异步请求,从而可轻松将Target集成到应用程序的现有异步工作流中。
支持的方法
.NET
Task<TargetDeliveryResponse> GetOffersAsync(TargetDeliveryRequest request);
Task<TargetDeliveryResponse> SendNotificationsAsync(TargetDeliveryRequest request);
Task<TargetAttributes> GetAttributesAsync(TargetDeliveryRequest request, params string[] mboxes);
示例
异步SDK API用法示例可能如下所示:
.NET
var deliveryRequest = new TargetDeliveryRequest.Builder()
.SetExecute(new ExecuteRequest(mboxes: new List<MboxRequest> { new MboxRequest(index: 1, name: "a1-serverside-ab") }))
.Build();
var response = await this.targetClient.GetOffersAsync(deliveryRequest);
var notificationRequest = new TargetDeliveryRequest.Builder()
.SetSessionId(response.Request.SessionId)
.SetTntId(response.Response?.Id?.TntId)
.SetNotifications(new List<Notification>
{
new (id: "1", type: MetricType.Display, timestamp: DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
mbox: new NotificationMbox("product1", "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"),
tokens: new List<string> { "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==" })
})
.Build();
var notificationResponse = await this.targetClient.SendNotificationsAsync(notificationRequest);
此示例假定您已初始化SDK。
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3