private async void powerSwitchWatcher_Added(binaryWatcher watcher, AllJoynServiceInfo args) { if (_powerSwitchConsumer == null && args.ObjectPath.Contains(_expectedBusObjectPath)) { var joinResult = await binaryConsumer.JoinSessionAsync(args, watcher); if (joinResult.Status == AllJoynStatus.Ok) { _powerSwitchConsumer = joinResult.Consumer; _powerSwitchConsumer.SessionLost += this.Consumer_SessionLost; // subscribe to value changes _powerSwitchConsumer.ValueChanged += this.powerSwitchConsumer_ValueChanged; // populate initial values var valueResult = await _powerSwitchConsumer.GetValueAsync(); if (valueResult.Status != AllJoynStatus.Ok) { return; } this.IsOn = valueResult.Value; this.IsConnected = true; } } }
protected override void OnStart() { _audioWatcher = new audioWatcher(this.CreateBusAttachment(ref _audioBusAttachment)); _audioWatcher.Added += this.audioWatcher_Added; _audioWatcher.Start(); _channelWatcher = new channelWatcher(this.CreateBusAttachment(ref _channelBusAttachment)); _channelWatcher.Added += this.channelWatcher_Added; _channelWatcher.Start(); _powerSwitchWatcher = new binaryWatcher(this.CreateBusAttachment(ref _powerSwitchBusAttachment)); _powerSwitchWatcher.Added += this.powerSwitchWatcher_Added; _powerSwitchWatcher.Start(); }
protected override void OnStart() { _modeWatcher = new modeWatcher(this.CreateBusAttachment(ref _modeBusAttachment)); _modeWatcher.Added += this.modeWatcher_Added; _modeWatcher.Start(); _airflowWatcher = new airflowWatcher(this.CreateBusAttachment(ref _airflowBusAttachment)); _airflowWatcher.Added += this.airflowWatcher_Added; _airflowWatcher.Start(); _binaryWatcher = new binaryWatcher(this.CreateBusAttachment(ref _binaryBusAttachment)); _binaryWatcher.Added += this.binaryWatcher_Added; _binaryWatcher.Start(); _temperatureWatcher = new temperatureWatcher(this.CreateBusAttachment(ref _temperatureBusAttachment)); _temperatureWatcher.Added += this.temperatureWatcher_Added; _temperatureWatcher.Start(); }