|
|
|
@ -28,11 +28,13 @@ namespace IoT.Shared.Services
|
|
|
|
|
private bool disposed = false;
|
|
|
|
|
private string _notifyHost;
|
|
|
|
|
private HubConnection Connection;
|
|
|
|
|
private readonly IHostApplicationLifetime _lifetime;
|
|
|
|
|
private readonly IServiceProvider _applicationServices;
|
|
|
|
|
private readonly ILogger<IoTNodeClient> _logger;
|
|
|
|
|
|
|
|
|
|
public IoTNodeClient(IServiceProvider applicationServices, ILogger<IoTNodeClient> logger)
|
|
|
|
|
public IoTNodeClient(IHostApplicationLifetime lifetime, IServiceProvider applicationServices, ILogger<IoTNodeClient> logger)
|
|
|
|
|
{
|
|
|
|
|
this._lifetime = lifetime;
|
|
|
|
|
this._applicationServices = applicationServices;
|
|
|
|
|
this._logger = logger;
|
|
|
|
|
}
|
|
|
|
@ -132,7 +134,7 @@ namespace IoT.Shared.Services
|
|
|
|
|
private void InitConnection()
|
|
|
|
|
{
|
|
|
|
|
this._notifyHost = GetSetting("notify:host");
|
|
|
|
|
var organ= GetSetting("organ");
|
|
|
|
|
var organ = GetSetting("organ");
|
|
|
|
|
var url = $"{this._notifyHost}/hub?type=node&organ={organ}&group={GetSetting("sn")}";
|
|
|
|
|
this._logger.LogDebug($"init connection for {url}");
|
|
|
|
|
if (this.Connection != null)
|
|
|
|
@ -235,7 +237,11 @@ namespace IoT.Shared.Services
|
|
|
|
|
var dataService = scope.ServiceProvider.GetService<DataService>();
|
|
|
|
|
var eventPublisher = scope.ServiceProvider.GetService<IEventPublisher>();
|
|
|
|
|
|
|
|
|
|
if (method == "UpdateNode")
|
|
|
|
|
if (method == Methods.StopNode)
|
|
|
|
|
{
|
|
|
|
|
this._lifetime.StopApplication();
|
|
|
|
|
}
|
|
|
|
|
else if (method == Methods.UploadNode)
|
|
|
|
|
{
|
|
|
|
|
this.OnConnected();
|
|
|
|
|
}
|
|
|
|
|