public static string Subscribe <TPayload>( this IMessageBrokerService messageBrokerService, string topic, Action <Message <TPayload> > callback, Func <Message <TPayload>, bool> filter = null) where TPayload : class { var id = Guid.NewGuid().ToString(); var payloadType = typeof(TPayload).Name; var messageSubscription = new MessageSubscription { Id = id, Topic = topic, PayloadType = typeof(TPayload).Name, Callback = c => callback(new Message <TPayload>(topic, new MessagePayload <TPayload>(payloadType, c.Payload.Content.ToObject <TPayload>()))) }; if (filter != null) { messageSubscription.Filter = c => filter(new Message <TPayload>(topic, new MessagePayload <TPayload>(payloadType, c.Payload.Content.ToObject <TPayload>()))); } messageBrokerService.Subscribe(messageSubscription); return(id); }
public static string Subscribe( this IMessageBrokerService messageBrokerService, string topic, string payloadType, Action <Message <JObject> > callback, Func <Message <JObject>, bool> filter = null) { if (messageBrokerService == null) { throw new ArgumentNullException(nameof(messageBrokerService)); } if (topic == null) { throw new ArgumentNullException(nameof(topic)); } if (callback == null) { throw new ArgumentNullException(nameof(callback)); } var id = Guid.NewGuid().ToString(); messageBrokerService.Subscribe(new MessageSubscription { Id = id, Topic = topic, PayloadType = payloadType, Filter = filter, Callback = callback }); return(id); }
public MotionDetector(string id, IMotionDetectorAdapter adapter, ISchedulerService schedulerService, ISettingsService settingsService, IMessageBrokerService messageBroker) : base(id) { if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); _schedulerService = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService)); adapter.StateChanged += UpdateState; settingsService.CreateSettingsMonitor <MotionDetectorSettings>(this, s => { Settings = s.NewSettings; if (s.OldSettings != null && s.OldSettings.IsEnabled != s.NewSettings.IsEnabled) { HandleIsEnabledStateChanged(); } }); _commandExecutor.Register <ResetCommand>(c => adapter.Refresh()); }
public UpperBathroomConfiguration( CCToolsDeviceService ccToolsBoardService, IDeviceRegistryService deviceService, ISchedulerService schedulerService, IAreaRegistryService areaService, ISettingsService settingsService, AutomationFactory automationFactory, ActuatorFactory actuatorFactory, SensorFactory sensorFactory, IMessageBrokerService messageBroker, IDeviceMessageBrokerService deviceMessageBrokerService, ILogService logService) { _messageBroker = messageBroker; _deviceMessageBrokerService = deviceMessageBrokerService; _logService = logService; _ccToolsBoardService = ccToolsBoardService ?? throw new ArgumentNullException(nameof(ccToolsBoardService)); _deviceService = deviceService ?? throw new ArgumentNullException(nameof(deviceService)); _schedulerService = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService)); _areaService = areaService ?? throw new ArgumentNullException(nameof(areaService)); _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); _automationFactory = automationFactory ?? throw new ArgumentNullException(nameof(automationFactory)); _actuatorFactory = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory)); _sensorFactory = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory)); _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(sensorFactory)); }
public static IRollerShutter ConnectWith( this IRollerShutter rollerShutter, IButton upButton, IButton downButton, IMessageBrokerService messageBroker) { if (rollerShutter == null) { throw new ArgumentNullException(nameof(rollerShutter)); } if (upButton == null) { throw new ArgumentNullException(nameof(upButton)); } if (downButton == null) { throw new ArgumentNullException(nameof(downButton)); } if (messageBroker == null) { throw new ArgumentNullException(nameof(messageBroker)); } upButton.CreatePressedShortTrigger(messageBroker).Attach(() => HandleBlindButtonPressedEvent(rollerShutter, VerticalMovingStateValue.MovingUp)); downButton.CreatePressedShortTrigger(messageBroker).Attach(() => HandleBlindButtonPressedEvent(rollerShutter, VerticalMovingStateValue.MovingDown)); return(rollerShutter); }
public TransportationController( IMessageBrokerService messageBrokerService, IAutoMapperService autoMapperService) { _messageBrokerService = messageBrokerService; _autoMapperService = autoMapperService; }
public virtual void ConnectToParentBroker(String parentBrokerURL) { parentBroker = (IMessageBrokerService)Activator.GetObject( typeof(IMessageBrokerService), parentBrokerURL); replicatedBrokerList = parentBroker.ReplicatedBrokerList; }
public Button(string id, IButtonAdapter adapter, ITimerService timerService, ISettingsService settingsService, IMessageBrokerService messageBroker, ILogService logService) : base(id) { if (adapter == null) { throw new ArgumentNullException(nameof(adapter)); } if (settingsService == null) { throw new ArgumentNullException(nameof(settingsService)); } _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _log = logService?.CreatePublisher(id) ?? throw new ArgumentNullException(nameof(logService)); settingsService.CreateSettingsMonitor <ButtonSettings>(this, s => Settings = s.NewSettings); _pressedLongTimeout = new Timeout(timerService); _pressedLongTimeout.Elapsed += (s, e) => { _messageBroker.Publish(Id, new ButtonPressedLongEvent()); }; adapter.StateChanged += UpdateState; _commandExecutor.Register <ResetCommand>(); _commandExecutor.Register <PressCommand>(c => PressInternal(c.Duration)); }
public FinishOrderHandler( ICouponRepository couponRepository, IMessageBrokerService messageBrokerService ) { this.couponRepository = couponRepository; this.messageBrokerService = messageBrokerService; }
public TransportationHubOrchestrator( IMessageBrokerService messageBrokerService, IHubContext <TransportationHub> hubContext) { _hubContext = hubContext; _transportationSubscriptionClient = messageBrokerService.BuildQueueClient("Processed-Post-Captured-Locations-Queue"); }
public MainPageViewModel( INavigationService navigationService, IMessageBrokerService messageBrokerService ) { _navigationService = navigationService; _messageBrokerService = messageBrokerService; }
public SensorFactory(ITimerService timerService, ISchedulerService schedulerService, ISettingsService settingsService, IMessageBrokerService messageBroker, ILogService logService) { _logService = logService ?? throw new ArgumentNullException(nameof(logService)); _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _timerService = timerService ?? throw new ArgumentNullException(nameof(timerService)); _schedulerService = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService)); _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); }
public void AddBroker(ProcessHeader brokerHeader) { IMessageBrokerService brokerService = (IMessageBrokerService)Activator.GetObject( typeof(IMessageBrokerService), brokerHeader.ProcessURL); adjacentBrokerList.Add(brokerHeader, brokerService); }
private async Task PublishMissingMessages() { using (IServiceScope scope = _serviceProvider.CreateScope()) { IMessageBrokerService _messageBrokerService = scope.ServiceProvider.GetRequiredService <IMessageBrokerService>(); await _messageBrokerService.PublishMissingMessages(); } }
public Window(string id, IWindowAdapter adapter, ISettingsService settingsService, IMessageBrokerService messageBroker) : base(id) { _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _adapter = adapter ?? throw new ArgumentNullException(nameof(adapter)); _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); adapter.StateChanged += (s, e) => Update(e); }
public App( IConfiguration config, IMessageBrokerService messageBrokerService, IMediator mediator ) { _config = config; this.messageBrokerService = messageBrokerService; this.mediator = mediator; }
public DetailPageViewModel( INavigationService navigationService, IMessageBrokerService messageBrokerService ) { _navigationService = navigationService; LabelText = messageBrokerService .ReceiveMessage <MasterDetailNavigationMessage>() ?.Message ?? "Message receive failed"; }
public GameLogic(IMessageBrokerService messageBroker, ITimeService timeService, IDataProvider dataProvider, IConfigsProvider configsProvider) { MessageBrokerService = messageBroker; TimeService = timeService; ConfigsProvider = configsProvider; AppLogic = new AppLogic(this, dataProvider); CurrencyLogic = new CurrencyLogic(this, dataProvider); GameIdLogic = new GameIdLogic(this, dataProvider); }
public static bool HasSubscribers <TPayload>(this IMessageBrokerService messageBrokerService, string topic) where TPayload : class { if (messageBrokerService == null) { throw new ArgumentNullException(nameof(messageBrokerService)); } if (topic == null) { throw new ArgumentNullException(nameof(topic)); } return(messageBrokerService.HasSubscribers(topic, typeof(TPayload).Name)); }
public static ITrigger CreatePressedLongTrigger(this IButton button, IMessageBrokerService messageBroker) { if (button == null) { throw new ArgumentNullException(nameof(button)); } if (messageBroker == null) { throw new ArgumentNullException(nameof(messageBroker)); } return(messageBroker.CreateTrigger <ButtonPressedLongEvent>(button.Id)); }
public MessageBroker(ProcessHeader processHeader) : base(processHeader) { topicRoot = new Topic("", null); mainBroker = null; subscriberList = new Dictionary <ProcessHeader, ISubscriberService>(); adjacentBrokerList = new Dictionary <ProcessHeader, IMessageBrokerService>(); replicatedBrokerList = new Dictionary <ProcessHeader, IMessageBrokerService>(); brokerSeqNumList = new Dictionary <String, int>(); orderManager = new EventOrderManager(); secondaryManager = new EventOrderManager(); locker = new Object(); rootSeqNumber = 0; }
public BathroomFanAutomation(string id, IFan fan, ISchedulerService schedulerService, ISettingsService settingsService, IMessageBrokerService messageBroker) : base(id) { if (settingsService == null) { throw new ArgumentNullException(nameof(settingsService)); } _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _fan = fan ?? throw new ArgumentNullException(nameof(fan)); _schedulerService = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService)); settingsService.CreateSettingsMonitor <BathroomFanAutomationSettings>(this, s => Settings = s.NewSettings); }
public LivingRoomConfiguration( IDeviceRegistryService deviceService, IAreaRegistryService areaService, CCToolsDeviceService ccToolsBoardService, ActuatorFactory actuatorFactory, SensorFactory sensorFactory, IMessageBrokerService messageBroker) { _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _deviceService = deviceService ?? throw new ArgumentNullException(nameof(deviceService)); _areaService = areaService ?? throw new ArgumentNullException(nameof(areaService)); _ccToolsBoardService = ccToolsBoardService ?? throw new ArgumentNullException(nameof(ccToolsBoardService)); _actuatorFactory = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory)); _sensorFactory = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory)); }
public TurnOnAndOffAutomation( string id, IDateTimeService dateTimeService, ISchedulerService schedulerService, ISettingsService settingsService, IDaylightService daylightService, IMessageBrokerService messageBroker) : base(id) { _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); _dateTimeService = dateTimeService ?? throw new ArgumentNullException(nameof(dateTimeService)); _schedulerService = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService)); _daylightService = daylightService ?? throw new ArgumentNullException(nameof(daylightService)); settingsService.CreateSettingsMonitor <TurnOnAndOffAutomationSettings>(this, s => Settings = s.NewSettings); }
public GameServices(IMessageBrokerService messageBrokerService, ITimeService timeService, IDataSaver dataSaver, IGameLogic gameLogic, IWorldObjectReferenceService worldObjectReference) { var networkService = new GameNetworkService(); NetworkService = networkService; MessageBrokerService = messageBrokerService; TimeService = timeService; WorldObjectReferenceService = worldObjectReference; DataSaver = dataSaver; CommandService = new CommandService <IGameLogic>(gameLogic, networkService); PoolService = new PoolService(); AssetResolverService = new AssetResolverService(); TickService = new TickService(); CoroutineService = new CoroutineService(); }
public Configuration( IDeviceRegistryService deviceRegistryService, IGpioService gpioService, IAreaRegistryService areaService, ActuatorFactory actuatorFactory, SensorFactory sensorFactory, AutomationFactory automationFactory, IMessageBrokerService messageBroker) { _deviceRegistryService = deviceRegistryService ?? throw new ArgumentNullException(nameof(deviceRegistryService)); _gpioService = gpioService ?? throw new ArgumentNullException(nameof(gpioService)); _areaService = areaService ?? throw new ArgumentNullException(nameof(areaService)); _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _actuatorFactory = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory)); _sensorFactory = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory)); _automationFactory = automationFactory ?? throw new ArgumentNullException(nameof(automationFactory)); }
public OfficeConfiguration( IDeviceRegistryService deviceService, IAreaRegistryService areaService, IRemoteSocketService remoteSocketService, ActuatorFactory actuatorFactory, SensorFactory sensorFactory, IMessageBrokerService messageBroker, IDeviceMessageBrokerService deviceMessageBroker, ILogService logService) { _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _deviceMessageBroker = deviceMessageBroker ?? throw new ArgumentNullException(nameof(deviceMessageBroker)); _logService = logService ?? throw new ArgumentNullException(nameof(logService)); _deviceService = deviceService ?? throw new ArgumentNullException(nameof(deviceService)); _areaService = areaService ?? throw new ArgumentNullException(nameof(areaService)); _remoteSocketService = remoteSocketService ?? throw new ArgumentNullException(nameof(remoteSocketService)); _actuatorFactory = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory)); _sensorFactory = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory)); }
public OfficeConfiguration( IDeviceRegistryService deviceService, IAreaRegistryService areaService, OutpostDeviceService outpostDeviceService, CCToolsDeviceService ccToolsBoardService, IRemoteSocketService remoteSocketService, ActuatorFactory actuatorFactory, SensorFactory sensorFactory, IMessageBrokerService messageBroker) { _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _outpostDeviceService = outpostDeviceService ?? throw new ArgumentNullException(nameof(outpostDeviceService)); _deviceService = deviceService ?? throw new ArgumentNullException(nameof(deviceService)); _areaService = areaService ?? throw new ArgumentNullException(nameof(areaService)); //_ccToolsBoardService = ccToolsBoardService ?? throw new ArgumentNullException(nameof(ccToolsBoardService)); _remoteSocketService = remoteSocketService ?? throw new ArgumentNullException(nameof(remoteSocketService)); _actuatorFactory = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory)); _sensorFactory = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory)); }
public LowerBathroomConfiguration( IDeviceRegistryService deviceService, ISchedulerService schedulerService, IAreaRegistryService areaService, ISettingsService settingsService, AutomationFactory automationFactory, ActuatorFactory actuatorFactory, SensorFactory sensorFactory, IMessageBrokerService messageBroker) { _messageBroker = messageBroker ?? throw new ArgumentNullException(nameof(messageBroker)); _settingsService = settingsService ?? throw new ArgumentNullException(nameof(settingsService)); _deviceService = deviceService ?? throw new ArgumentNullException(nameof(deviceService)); _schedulerService = schedulerService ?? throw new ArgumentNullException(nameof(schedulerService)); _areaService = areaService ?? throw new ArgumentNullException(nameof(areaService)); _automationFactory = automationFactory ?? throw new ArgumentNullException(nameof(automationFactory)); _actuatorFactory = actuatorFactory ?? throw new ArgumentNullException(nameof(actuatorFactory)); _sensorFactory = sensorFactory ?? throw new ArgumentNullException(nameof(sensorFactory)); }
public static ITrigger CreateTrigger <TPayload>( this IMessageBrokerService messageBrokerService, string topic, Func <Message <TPayload>, bool> filter = null) where TPayload : class { if (messageBrokerService == null) { throw new ArgumentNullException(nameof(messageBrokerService)); } if (topic == null) { throw new ArgumentNullException(nameof(topic)); } var trigger = new Trigger(); messageBrokerService.Subscribe(topic, c => trigger.Execute(), filter); return(trigger); }