private void powerSwitchConsumer_ValueChanged(binaryConsumer consumer, object value) { if (value is bool) { this.IsOn = (bool)value; } }
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; } } }