|
|
@@ -1,18 +1,17 @@
|
|
|
namespace EEMSServerCore.HubSender;
|
|
|
|
|
|
-public class ClientCaller(ClientManager clientManager) : IClientProvider
|
|
|
+public class ClientCaller : IClientProvider
|
|
|
{
|
|
|
- private Task<bool> SendAsync(string name)
|
|
|
+ private Task<bool> SendAsync(Guid guid, string name)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
return Task.FromResult(false);
|
|
|
-
|
|
|
- if (clientManager.UIClient is null)
|
|
|
+ if (ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- clientManager.UIClient.SendAsync("test");
|
|
|
+ client.SendAsync(name);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
@@ -21,17 +20,17 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
|
|
|
return Task.FromResult(true);
|
|
|
}
|
|
|
|
|
|
- private Task<bool> SendAsync<T>(string name, T para)
|
|
|
+ private Task<bool> SendAsync<T>(Guid guid, string name, T para)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
- if (clientManager.UIClient is null)
|
|
|
+ if (ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- clientManager.UIClient.SendAsync(name, para);
|
|
|
+ client.SendAsync(name, para);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
@@ -40,17 +39,17 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
|
|
|
return Task.FromResult(true);
|
|
|
}
|
|
|
|
|
|
- private Task<bool> SendAsync<T1, T2>(string name, T1 para1, T2 para2)
|
|
|
+ private Task<bool> SendAsync<T1, T2>(Guid guid, string name, T1 para1, T2 para2)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
- if (clientManager.UIClient is null)
|
|
|
+ if (!ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- clientManager.UIClient.SendAsync(name, para1, para2);
|
|
|
+ client.SendAsync(name, para1, para2);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
@@ -59,17 +58,17 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
|
|
|
return Task.FromResult(true);
|
|
|
}
|
|
|
|
|
|
- private Task<bool> SendAsync<T1, T2, T3>(string name, T1 para1, T2 para2, T3 para3)
|
|
|
+ private Task<bool> SendAsync<T1, T2, T3>(Guid guid, string name, T1 para1, T2 para2, T3 para3)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
- if (clientManager.UIClient is null)
|
|
|
+ if (ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- clientManager.UIClient.SendAsync(name, para1, para2, para3);
|
|
|
+ client.SendAsync(name, para1, para2, para3);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
@@ -78,17 +77,17 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
|
|
|
return Task.FromResult(true);
|
|
|
}
|
|
|
|
|
|
- private Task<bool> SendAsync<T1, T2, T3, T4>(string name, T1 para1, T2 para2, T3 para3, T4 para4)
|
|
|
+ private Task<bool> SendAsync<T1, T2, T3, T4>(Guid guid, string name, T1 para1, T2 para2, T3 para3, T4 para4)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(name))
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
- if (clientManager.UIClient is null)
|
|
|
+ if (ClientManager.DeviceClients.TryGetValue(guid, out ISingleClientProxy? client) || client is null)
|
|
|
return Task.FromResult(false);
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- clientManager.UIClient.SendAsync(name, para1, para2, para3, para4);
|
|
|
+ client.SendAsync(name, para1, para2, para3, para4);
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
@@ -97,8 +96,8 @@ public class ClientCaller(ClientManager clientManager) : IClientProvider
|
|
|
return Task.FromResult(true);
|
|
|
}
|
|
|
|
|
|
- Task IClientProvider.RequestFile(Guid guid, FileType fileType)
|
|
|
+ Task<bool> IClientProvider.RequestFile(Guid guid, FileType fileType)
|
|
|
{
|
|
|
- return this.SendAsync("RequestFile", guid, fileType);
|
|
|
+ return this.SendAsync(guid, "RequestFile", guid, fileType);
|
|
|
}
|
|
|
}
|