private async Task HandleMeasurementEvent(MeasurementEvent measurementEvent)
        {
            await _measurementsRepository.Write(new WriteRequest(measurementEvent.DeviceId, measurementEvent.Points));

            var channelEvent = new ChannelEvent(measurementEvent.DeviceId, Events.MeasurementOccured, measurementEvent);

            _hubContext.Clients.Group(measurementEvent.DeviceId).EventArrived(channelEvent);
        }
        private async Task HandleProperiesChangedEvent(PropertiesChangedEvent propertiesChangedEvent)
        {
            var device = new DeviceDescriptor(propertiesChangedEvent.DeviceId, propertiesChangedEvent.Properties);
            await _deviceRepository.InsertOrUpdate(device);

            var channelEvent = new ChannelEvent(propertiesChangedEvent.DeviceId, Events.DeviceUpdated, propertiesChangedEvent);

            _hubContext.Clients.Group(device.DeviceId).EventArrived(channelEvent);
        }
        private async Task HandleRegisterEvent(RegisterEvent registerEvent)
        {
            var device = new DeviceDescriptor(registerEvent.DeviceId, registerEvent.Properties);
            await _deviceRepository.InsertOrUpdate(device);

            var channelEvent = new ChannelEvent(registerEvent.DeviceId, Events.DeviceRegistered, registerEvent);

            _hubContext.Clients.Group(device.DeviceId).EventArrived(channelEvent);
        }
 public void Publish(ChannelEvent channelEvent)
 {
     if (_typeDictionary.TryGetValue(channelEvent.EventName, out Type eventType))
     {
         var token     = (JToken)channelEvent.Data;
         var eventData = token.ToObject(eventType);
         _publisher.Publish(eventData);
     }
     else
     {
         _publisher.Publish(new ErrorEvent("Unknown published message."));
     }
 }