private async void channelWatcher_Added(channelWatcher watcher, AllJoynServiceInfo args) { if (_channelConsumer == null && args.ObjectPath.Contains(_expectedBusObjectPath)) { var joinSessionResult = await channelConsumer.JoinSessionAsync(args, watcher); if (joinSessionResult.Status == AllJoynStatus.Ok) { _channelConsumer = joinSessionResult.Consumer; _channelConsumer.SessionLost += this.Consumer_SessionLost; // subscribe to value changes _channelConsumer.ChannelUpDownChanged += this.channelConsumer_ChannelUpDownChanged; // populate initial values var channelUpDownResult = await _channelConsumer.GetChannelUpDownAsync(); if (channelUpDownResult.Status != AllJoynStatus.Ok) { return; } this.ChannelUpDown = channelUpDownResult.ChannelUpDown; 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(); }