various changes and corrections for sending data
This commit is contained in:
parent
42f7e02a7f
commit
3ca5768d6e
@ -31,7 +31,9 @@ public class Transmitter
|
|||||||
|
|
||||||
Uri uri = new Uri(BaseUrl, "Push/Elements");
|
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)
|
public async Task SendAsync(Element element, CancellationToken tk = default)
|
||||||
|
|||||||
@ -119,6 +119,8 @@ if(uri == null)
|
|||||||
|
|
||||||
// Initialisation
|
// Initialisation
|
||||||
Transmitter transmitter = new();
|
Transmitter transmitter = new();
|
||||||
|
transmitter.BaseUrl = uri;
|
||||||
|
|
||||||
FileSystemWatcher configWatcher;
|
FileSystemWatcher configWatcher;
|
||||||
Console.WriteLine($"Salmon.Service started at {DateTime.Now}.");
|
Console.WriteLine($"Salmon.Service started at {DateTime.Now}.");
|
||||||
if(configpath != null && watch_config == true)
|
if(configpath != null && watch_config == true)
|
||||||
@ -168,7 +170,7 @@ while ( true )
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await transmitter.SendAsync(uri, tosend);
|
await transmitter.SendAsync(tosend);
|
||||||
}
|
}
|
||||||
catch(HttpRequestException e)
|
catch(HttpRequestException e)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"Url":"http://localhost:5009/api/Push",
|
"Url":"http://salmon.voie93quarts.fr/api/Push",
|
||||||
"Period":15000,
|
"Period":15000,
|
||||||
"Watch":[
|
"Watch":[
|
||||||
{
|
{
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace Salmon.Web.Controllers
|
|||||||
return els;
|
return els;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost("Push")]
|
[HttpPost("Push/Elements")]
|
||||||
public void Post([FromBody] IEnumerable<Triplet> triplets)
|
public void Post([FromBody] IEnumerable<Triplet> triplets)
|
||||||
{
|
{
|
||||||
Instance.Set(triplets);
|
Instance.Set(triplets);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user