async void OnAdded(FezHatWatcher sender, AllJoynServiceInfo args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async() => { // Get the about data. var aboutData = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, _busAttachment, args.SessionPort); Debug.WriteLine("Found {0} on {1} from manufacturer: {2}. Connecting...", aboutData.AppName, aboutData.DeviceName, aboutData.Manufacturer); var joinResult = await FezHatConsumer.JoinSessionAsync(args, sender); if (joinResult.Status != AllJoynStatus.Ok) { return; } FezHats.Add(new FezHatItem() { UniqueName = args.UniqueName, DefaultAppName = aboutData.AppName, ModelNumber = aboutData.ModelNumber, DateOfManufacture = aboutData.DateOfManufacture, Consumer = joinResult.Consumer }); joinResult.Consumer.SessionLost += OnFezHatLost; joinResult.Consumer.Signals.ButtonDio18PressedReceived += Signals_ButtonDio18PressedReceived; } ); }
void StartDiscoveringFezHats() { _busAttachment = new AllJoynBusAttachment(); _busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.SrpAnonymous); _fezHatWatcher = new FezHatWatcher(_busAttachment); _fezHatWatcher.Added += OnAdded; _fezHatWatcher.Start(); }
async void OnAdded(FezHatWatcher sender, AllJoynServiceInfo args) { await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () => { // Get the about data. var aboutData = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, _busAttachment, args.SessionPort); Debug.WriteLine("Found {0} on {1} from manufacturer: {2}. Connecting...", aboutData.AppName, aboutData.DeviceName, aboutData.Manufacturer); var joinResult = await FezHatConsumer.JoinSessionAsync(args, sender); if (joinResult.Status != AllJoynStatus.Ok) return; FezHats.Add(new FezHatItem() { UniqueName = args.UniqueName, DefaultAppName = aboutData.AppName, ModelNumber = aboutData.ModelNumber, DateOfManufacture = aboutData.DateOfManufacture, Consumer = joinResult.Consumer }); joinResult.Consumer.SessionLost += OnFezHatLost; joinResult.Consumer.Signals.ButtonDio18PressedReceived += Signals_ButtonDio18PressedReceived; } ); }