123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- using Device;
- using EEMSClientCore;
- using EEMSUIClientCore;
- using ServiceBase;
- namespace TestSignalRClient;
- internal class Program
- {
- static void Main(string[] args)
- {
- UITest test = new();
- test.Test();
- Thread.Sleep(-1);
- }
- }
- internal class UITest : IUIProvider
- {
- public void Test()
- {
- HubBase hubBase = new();
- hubBase.Initialize(this);
- bool b = hubBase.Open("127.0.0.1", 50054, "UIHub");
- Console.WriteLine($"Open UI Client {b}");
- }
- public Task<bool> InsertNewDevice(DeviceInfo deviceInfo)
- {
- Console.WriteLine($"InsertNewDevice {deviceInfo.DeviceName} {deviceInfo.Guid}");
- return Task.FromResult(true);
- }
- public Task<bool> UpdateDevice(DeviceInfo device)
- {
- Console.WriteLine($"UpdateDevice {device.DeviceName} {device.Guid}");
- return Task.FromResult(true);
- }
- public Task<bool> UpdateDeviceList(IEnumerable<DeviceInfo> device)
- {
- foreach (var deviceInfo in device)
- {
- Console.WriteLine($"UpdateDeviceList {deviceInfo.DeviceName} {deviceInfo.Guid}");
- }
- return Task.FromResult(true);
- }
- public Task<bool> UpdateRealtimeData(Guid guid, Dictionary<string, object> data)
- {
- Console.WriteLine($"UpdateRealtimeData {guid} {data.Count}");
- foreach (var item in data)
- {
- Console.WriteLine($"UpdateRealtimeData {item.Key} {item.Value}");
- }
- return Task.FromResult(true);
- }
- public Task<bool> OnlineStatusNotify(Guid guid, bool onlineStatus)
- {
- Console.WriteLine($"OnlineStatusNotify {guid} {onlineStatus}");
- return Task.FromResult(true);
- }
- }
- internal class ClientTest
- {
- public void Test()
- {
- IClientBaseProvider baseProvider = new ClientBaseProvider();
- ClientCaller hubSender = new(baseProvider);
- IClientCaller caller = hubSender;
- hubSender.Initialize();
- hubSender.Open("localhost", 50054, "ClientHub");
- DeviceInfo deviceInfo = new()
- {
- };
- Guid guid = caller.RegisterDevice(deviceInfo).Result;
- Console.WriteLine(guid);
- }
- }
- internal class ClientBaseProvider : IClientBaseProvider
- {
- public string? RecipePath { get; set; }
- public string? ConfigPath { get; set; }
- string? IClientBaseProvider.RecipePath { get; set; }
- string? IClientBaseProvider.ConfigPath { get; set; }
- bool IClientBaseProvider.AllowReceiveFile()
- {
- return true;
- }
- void IClientBaseProvider.FileReceivedNotify(FileType fileType, string path)
- {
- }
- void IClientBaseProvider.StartFileReceiveNotify(FileType fileType)
- {
- }
- }
|