various changes and corrections for sending data

This commit is contained in:
taywon 2024-05-19 18:25:10 +02:00
parent 42f7e02a7f
commit 3ca5768d6e
4 changed files with 8 additions and 4 deletions

View File

@ -31,7 +31,9 @@ public class Transmitter
Uri uri = new Uri(BaseUrl, "Push/Elements");
await Client.PostAsJsonAsync(uri, elements, tk);
var result = await Client.PostAsJsonAsync(uri, elements, tk);
if (!result.IsSuccessStatusCode)
throw new Exception($"SendAsync call return code {result.StatusCode} when call {uri}.");
}
public async Task SendAsync(Element element, CancellationToken tk = default)

View File

@ -119,6 +119,8 @@ if(uri == null)
// Initialisation
Transmitter transmitter = new();
transmitter.BaseUrl = uri;
FileSystemWatcher configWatcher;
Console.WriteLine($"Salmon.Service started at {DateTime.Now}.");
if(configpath != null && watch_config == true)
@ -168,7 +170,7 @@ while ( true )
try
{
await transmitter.SendAsync(uri, tosend);
await transmitter.SendAsync(tosend);
}
catch(HttpRequestException e)
{

View File

@ -1,5 +1,5 @@
{
"Url":"http://localhost:5009/api/Push",
"Url":"http://salmon.voie93quarts.fr/api/Push",
"Period":15000,
"Watch":[
{

View File

@ -33,7 +33,7 @@ namespace Salmon.Web.Controllers
return els;
}
[HttpPost("Push")]
[HttpPost("Push/Elements")]
public void Post([FromBody] IEnumerable<Triplet> triplets)
{
Instance.Set(triplets);