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(); }
private async void modeWatcher_Added(modeWatcher watcher, AllJoynServiceInfo args) { if (_modeConsumer == null && args.ObjectPath.Contains(_expectedBusObjectPath)) { var joinSessionResult = await modeConsumer.JoinSessionAsync(args, watcher); if (joinSessionResult.Status == AllJoynStatus.Ok) { _modeConsumer = joinSessionResult.Consumer; _modeConsumer.SessionLost += this.Consumer_SessionLost; // subscribe to value changes _modeConsumer.ModesChanged += this.modeConsumer_ModesChanged; _modeConsumer.SupportedModesChanged += this.modeConsumer_SupportedModesChanged; // populate initial values var modesResult = await _modeConsumer.GetModesAsync(); if (modesResult.Status != AllJoynStatus.Ok) { return; } this.Modes = modesResult.Modes; var supportedModesResult = await _modeConsumer.GetSupportedModesAsync(); if (supportedModesResult.Status != AllJoynStatus.Ok) { return; } this.SupportedModes = supportedModesResult.SupportedModes; this.IsConnected = true; } } }