/* 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 ControlPanelWatcher_Added(ControlPanelWatcher sender, AllJoynServiceInfo args) { ControlPanelJoinSessionResult joinResult = await ControlPanelConsumer.JoinSessionAsync(args, sender); AllJoynAboutDataView view = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, this.controlPanelWatcherBusAttachment, args.SessionPort); if (joinResult.Status == AllJoynStatus.Ok) { } }*/ private async void PressureWatcher_Added(PressureWatcher sender, AllJoynServiceInfo args) { PressureJoinSessionResult joinResult = await PressureConsumer.JoinSessionAsync(args, sender); // AllJoynAboutDataView view = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, this.pressureBusAttachment, args.SessionPort); // var device = SensorClient.Factory.AllJoynDeviceFactory.GetAllJoynDevice(view); if (joinResult.Status == AllJoynStatus.Ok) { PressureSensor newSensor = new PressureSensor(joinResult.Consumer, args.UniqueName); var dispatcher = CoreApplication.MainView.CoreWindow.Dispatcher; await dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { // if (PerssureSensorSessionStarted != null) // PerssureSensorSessionStarted.Invoke(newSensor, device); }); } else { throw new Exception(String.Format("Joining the session went wrong for PressureSensor {0}", args.UniqueName)); } }