|
@@ -1,9 +1,19 @@
|
|
|
-namespace EEMSService.Hubs;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.AspNetCore.Http.Features;
|
|
|
+using System.Net;
|
|
|
|
|
|
-internal partial class ClientsHub(DeviceManager deviceManager, ClientManager clientManager) : HubBase
|
|
|
+namespace EEMSService.Hubs;
|
|
|
+
|
|
|
+internal partial class ClientsHub(DeviceManager deviceManager, ClientManager clientManager, IEEMSBaseServerProvider provider) : HubBase
|
|
|
{
|
|
|
public override Task OnConnectedAsync()
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+ if (Context.Features.Get<IHttpConnectionFeature>() is IHttpConnectionFeature feature)
|
|
|
+ {
|
|
|
+ provider?.OnConnected(feature.RemoteIpAddress!.ToString(), (ushort)feature.RemotePort, ServiceHub.ClinetHub);
|
|
|
+ }
|
|
|
return base.OnConnectedAsync();
|
|
|
}
|
|
|
|
|
@@ -13,7 +23,10 @@ internal partial class ClientsHub(DeviceManager deviceManager, ClientManager cli
|
|
|
|
|
|
if (device is not null && device.Guid.HasValue)
|
|
|
clientManager.DeviceClients.TryRemove(device.Guid.Value, out _);
|
|
|
-
|
|
|
+ if (Context.Features.Get<IHttpConnectionFeature>() is IHttpConnectionFeature feature)
|
|
|
+ {
|
|
|
+ provider?.OnDisConnected(feature.RemoteIpAddress!.ToString(), (ushort)feature.RemotePort, ServiceHub.ClinetHub);
|
|
|
+ }
|
|
|
return base.OnDisconnectedAsync(exception);
|
|
|
}
|
|
|
|
|
@@ -22,11 +35,11 @@ internal partial class ClientsHub(DeviceManager deviceManager, ClientManager cli
|
|
|
deviceInfo.Guid ??= Guid.NewGuid();
|
|
|
deviceManager.LoginDevice(Context.ConnectionId, deviceInfo);
|
|
|
clientManager.DeviceClients[deviceInfo.Guid.Value] = Clients.Caller;
|
|
|
- Task.Factory.StartNew(() =>
|
|
|
- {
|
|
|
- Thread.Sleep(2000);
|
|
|
- clientManager.DeviceClients[deviceInfo.Guid.Value].SendAsync("RequestFile", Guid.NewGuid(), 1);
|
|
|
- });
|
|
|
+ //Task.Factory.StartNew(() =>
|
|
|
+ //{
|
|
|
+ // Thread.Sleep(2000);
|
|
|
+ // clientManager.DeviceClients[deviceInfo.Guid.Value].SendAsync("RequestFile", Guid.NewGuid(), 1);
|
|
|
+ //});
|
|
|
return Task.FromResult(deviceInfo.Guid.Value);
|
|
|
}
|
|
|
}
|