Skip to content

Commit 52e9e07

Browse files
committed
Fix wave builder - async, don't wait for request
1 parent a7533a8 commit 52e9e07

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

TbsCore/Helpers/HttpHelper.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using RestSharp;
22
using System;
33
using System.Net;
4+
using System.Threading.Tasks;
45
using TbsCore.Models.Access;
56
using TbsCore.Models.AccModels;
67

@@ -24,10 +25,20 @@ public static CookieContainer GetCookies(Account acc)
2425
return cookieContainer;
2526
}
2627

28+
public static async Task<string> SendPostReqAsync(Account acc, RestRequest req)
29+
{
30+
acc.Wb.RestClient.BaseUrl = new Uri(acc.AccInfo.ServerUrl);
31+
acc.Wb.RestClient.CookieContainer = GetCookies(acc);
32+
33+
var response = await acc.Wb.RestClient.ExecuteAsync(req);
34+
if (response.StatusCode != HttpStatusCode.OK) throw new Exception("SendGetReq failed!\n" + response.Content);
35+
36+
return response.Content;
37+
}
2738
public static string SendPostReq(Account acc, RestRequest req)
2839
{
2940
acc.Wb.RestClient.BaseUrl = new Uri(acc.AccInfo.ServerUrl);
30-
acc.Wb.RestClient.CookieContainer = HttpHelper.GetCookies(acc);
41+
acc.Wb.RestClient.CookieContainer = GetCookies(acc);
3142

3243
var response = acc.Wb.RestClient.Execute(req);
3344
if (response.StatusCode != HttpStatusCode.OK) throw new Exception("SendGetReq failed!\n" + response.Content);

TbsCore/Tasks/LowLevel/SendWaves.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public override async Task<TaskRes> Execute(Account acc)
202202
{
203203
lastSent = DateTime.Now;
204204
acc.Logger.Information($"{DateTime.Now.Second}.{DateTime.Now.Millisecond}] Sending wave {i + 1}");
205-
_ = HttpHelper.SendPostReq(acc, wavesReady[i].Request);
205+
_ = HttpHelper.SendPostReqAsync(acc, wavesReady[i].Request);
206206

207207
// Wait +- 10% selected delay
208208
var delay = SendWaveModels[i].DelayMs;

0 commit comments

Comments
 (0)