public static void OnUserDeviceStateChanged(DeviceStateChangedEvent deviceStateChangedEvent) { var context = GlobalHost.ConnectionManager.GetHubContext<UsersHub>(); if (UsersConnections.ContainsKey(deviceStateChangedEvent.AppUserId)) { UserDeviceService userDeviceService = new UserDeviceService(); var device = userDeviceService.GetById(deviceStateChangedEvent.DeviceId); if (device != null) { var connection = UsersConnections[deviceStateChangedEvent.AppUserId]; context.Clients.Client(connection.ConnectionId).notifyAboutDeviceStateChange(new DeviceStateChangedNotification() { DateTime = deviceStateChangedEvent.DateTime, State = deviceStateChangedEvent.State, DeviceName = device.Name, Id = device.Id }); } } }
public void RegisterDeviceStateChangeEvent(DeviceStateChangedEvent deviceStateChangedEvent) { OnDeviceStateChangedEvent?.Invoke(deviceStateChangedEvent); }