Program.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using Device;
  2. using EEMSClientCore;
  3. using EEMSUIClientCore;
  4. using ServiceBase;
  5. namespace TestSignalRClient;
  6. internal class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. UITest test = new();
  11. test.Test();
  12. Thread.Sleep(-1);
  13. }
  14. }
  15. internal class UITest : IUIProvider
  16. {
  17. public void Test()
  18. {
  19. HubBase hubBase = new();
  20. hubBase.Initialize(this);
  21. bool b = hubBase.Open("127.0.0.1", 50054, "UIHub");
  22. Console.WriteLine($"Open UI Client {b}");
  23. }
  24. public Task<bool> InsertNewDevice(DeviceInfo deviceInfo)
  25. {
  26. Console.WriteLine($"InsertNewDevice {deviceInfo.DeviceName} {deviceInfo.Guid}");
  27. return Task.FromResult(true);
  28. }
  29. public Task<bool> UpdateDevice(DeviceInfo device)
  30. {
  31. Console.WriteLine($"UpdateDevice {device.DeviceName} {device.Guid}");
  32. return Task.FromResult(true);
  33. }
  34. public Task<bool> UpdateDeviceList(IEnumerable<DeviceInfo> device)
  35. {
  36. foreach (var deviceInfo in device)
  37. {
  38. Console.WriteLine($"UpdateDeviceList {deviceInfo.DeviceName} {deviceInfo.Guid}");
  39. }
  40. return Task.FromResult(true);
  41. }
  42. public Task<bool> UpdateRealtimeData(Guid guid, Dictionary<string, object> data)
  43. {
  44. Console.WriteLine($"UpdateRealtimeData {guid} {data.Count}");
  45. foreach (var item in data)
  46. {
  47. Console.WriteLine($"UpdateRealtimeData {item.Key} {item.Value}");
  48. }
  49. return Task.FromResult(true);
  50. }
  51. public Task<bool> OnlineStatusNotify(Guid guid, bool onlineStatus)
  52. {
  53. Console.WriteLine($"OnlineStatusNotify {guid} {onlineStatus}");
  54. return Task.FromResult(true);
  55. }
  56. }
  57. internal class ClientTest
  58. {
  59. public void Test()
  60. {
  61. IClientBaseProvider baseProvider = new ClientBaseProvider();
  62. ClientCaller hubSender = new(baseProvider);
  63. IClientCaller caller = hubSender;
  64. hubSender.Initialize();
  65. hubSender.Open("localhost", 50054, "ClientHub");
  66. DeviceInfo deviceInfo = new()
  67. {
  68. };
  69. Guid guid = caller.RegisterDevice(deviceInfo).Result;
  70. Console.WriteLine(guid);
  71. }
  72. }
  73. internal class ClientBaseProvider : IClientBaseProvider
  74. {
  75. public string? RecipePath { get; set; }
  76. public string? ConfigPath { get; set; }
  77. string? IClientBaseProvider.RecipePath { get; set; }
  78. string? IClientBaseProvider.ConfigPath { get; set; }
  79. bool IClientBaseProvider.AllowReceiveFile()
  80. {
  81. return true;
  82. }
  83. void IClientBaseProvider.FileReceivedNotify(FileType fileType, string path)
  84. {
  85. }
  86. void IClientBaseProvider.StartFileReceiveNotify(FileType fileType)
  87. {
  88. }
  89. }