added signar sync
parent
8597d5d0ba
commit
ad784c21e0
|
@ -17,6 +17,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.AspNet.SignalR.Core" Version="2.4.3" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0" />
|
||||||
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="4.0.0" />
|
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="4.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
|
|
@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||||
namespace API_SequentMicrosystems.Controllers
|
namespace API_SequentMicrosystems.Controllers
|
||||||
{
|
{
|
||||||
[Tags("Internal Saving Points (Recommended use only \"Actual\" endpoint for read all data at once. Saving points is not recomended)")]
|
[Tags("Internal Saving Points (Recommended use only \"Actual\" endpoint for read all data at once. Saving points is not recomended)")]
|
||||||
[Route("Points")]
|
[Route("api/Points")]
|
||||||
[ApiController]
|
[ApiController]
|
||||||
public class PointsController : ControllerBase
|
public class PointsController : ControllerBase
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
using Microsoft.AspNetCore.SignalR;
|
||||||
|
|
||||||
|
namespace API_SequentMicrosystems.Hubs
|
||||||
|
{
|
||||||
|
public class SyncHub : Hub
|
||||||
|
{
|
||||||
|
|
||||||
|
public async Task SyncClients()
|
||||||
|
{
|
||||||
|
await Clients.All.SendAsync("ClientsRequest");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SyncClientResponse(string clientID)
|
||||||
|
{
|
||||||
|
await Clients.All.SendAsync("ClientsResponse", clientID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SyncRequest(string clientID)
|
||||||
|
{
|
||||||
|
await Clients.All.SendAsync("SyncRequested", clientID);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SyncPoints(string clientID, object o)
|
||||||
|
{
|
||||||
|
await Clients.All.SendAsync("SyncPointsData", clientID, o);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task SyncRTD8TMChart(string clientID, object o)
|
||||||
|
{
|
||||||
|
await Clients.All.SendAsync("SyncRTD8TMChartData", clientID, o);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
using API_SequentMicrosystems.Hubs;
|
||||||
using API_SequentMicrosystems.Services;
|
using API_SequentMicrosystems.Services;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
@ -15,6 +16,7 @@ namespace API_SequentMicrosystems
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
|
|
||||||
builder.Services.AddControllers().AddNewtonsoftJson();
|
builder.Services.AddControllers().AddNewtonsoftJson();
|
||||||
|
builder.Services.AddSignalR();
|
||||||
|
|
||||||
builder.Services.AddSingleton<RTDDAService>();
|
builder.Services.AddSingleton<RTDDAService>();
|
||||||
builder.Services.AddSingleton<PointsService>();
|
builder.Services.AddSingleton<PointsService>();
|
||||||
|
@ -61,6 +63,8 @@ namespace API_SequentMicrosystems
|
||||||
app.Services.GetService<RTDDAService>();
|
app.Services.GetService<RTDDAService>();
|
||||||
app.Services.GetService<PointsService>();
|
app.Services.GetService<PointsService>();
|
||||||
|
|
||||||
|
app.MapHub<SyncHub>("/signalr/sync");
|
||||||
|
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
||||||
|
|
|
@ -6,9 +6,9 @@ namespace API_SequentMicrosystems.Services
|
||||||
{
|
{
|
||||||
public class PointsService
|
public class PointsService
|
||||||
{
|
{
|
||||||
private System.Timers.Timer _SaveTimer;
|
private System.Timers.Timer _SaveTimer; //timer for saving Points to file
|
||||||
private bool _SavePoints;
|
private bool _SavePoints;
|
||||||
private System.Timers.Timer? _timer;
|
private System.Timers.Timer? _timer; //Timer for creating new points
|
||||||
private RTDDAService _RTDDAService;
|
private RTDDAService _RTDDAService;
|
||||||
|
|
||||||
public PointsService(IConfiguration conf, RTDDAService _RTDDAS)
|
public PointsService(IConfiguration conf, RTDDAService _RTDDAS)
|
||||||
|
|
Loading…
Reference in New Issue