コード例 #1
0
		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
					});
				}
			}
		}
コード例 #2
0
		public void RegisterDeviceStateChangeEvent(DeviceStateChangedEvent deviceStateChangedEvent) {
			OnDeviceStateChangedEvent?.Invoke(deviceStateChangedEvent);
		}