/* ControlPanelWatcher ControlPanelWatcher = null; private AllJoynBusAttachment controlPanelWatcherBusAttachment = new AllJoynBusAttachment(); */ public WeatherStationConsumer() { this.humidityWatcher = new HumidityWatcher(this.humidityBusAttachment); this.humidityWatcher.Added += HumidityWatcher_Added; this.humidityWatcher.Start(); this.temperatureWatcher = new TemperatureWatcher(this.temperatureBusAttachment); this.temperatureWatcher.Added += TemperatureWatcher_Added; this.temperatureWatcher.Start(); this.pressureWatcher = new PressureWatcher(this.pressureBusAttachment); this.pressureWatcher.Added += PressureWatcher_Added; this.pressureWatcher.Start(); /* this.ControlPanelWatcher = new ControlPanelWatcher(controlPanelWatcherBusAttachment); this.ControlPanelWatcher.Added += ControlPanelWatcher_Added; this.ControlPanelWatcher.Start();*/ }
private async void TemperatureWatcher_Added(TemperatureWatcher sender, AllJoynServiceInfo args) { TemperatureJoinSessionResult joinResult = await TemperatureConsumer.JoinSessionAsync(args, sender); AllJoynAboutDataView view = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, this.temperatureBusAttachment, args.SessionPort); var device = SensorClient.Factory.AllJoynDeviceFactory.GetAllJoynDevice(view); if (joinResult.Status == AllJoynStatus.Ok) { TemperatureSensor newSensor = new TemperatureSensor(joinResult.Consumer, args.UniqueName); var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { if (TemperatureSensorSessionStarted != null) TemperatureSensorSessionStarted.Invoke(newSensor, device); }); } else { throw new Exception(String.Format("Joining the session went wrong for TemperatureSensor {0}", args.UniqueName)); } }