private async void Watcher_Added(OnboardingWatcher sender, AllJoynServiceInfo args) { // This demo supports a single onboarding producer, if there are multiple onboarding producers found, then they are ignored. // Another approach would be to create a list of all producers found and then allow the user to choose the one they want bool bAlreadyJoined = (Interlocked.CompareExchange(ref m_onboardSessionAlreadyJoined, 1, 0) == 1); if (bAlreadyJoined) { return; } UpdateStatusAsync("Joining session...", NotifyType.StatusMessage); OnboardingJoinSessionResult joinSessionResult = await OnboardingConsumer.JoinSessionAsync(args, sender); if (joinSessionResult.Status == AllJoynStatus.Ok) { UpdateStatusAsync("Session Joined.", NotifyType.ErrorMessage); DisposeConsumer(); m_consumer = joinSessionResult.Consumer; m_consumer.SessionLost += Consumer_SessionLost; GetOnboardeeNetworkListAsync(); } else { UpdateStatusAsync(string.Format("Attempt to join session failed with AllJoyn error: 0x{0:X}.", joinSessionResult.Status), NotifyType.ErrorMessage); } }
private async void Watcher_Added(OnboardingWatcher sender, AllJoynServiceInfo args) { UpdateStatusAsync("Joining session...", NotifyType.StatusMessage); OnboardingJoinSessionResult joinSessionResult = await OnboardingConsumer.JoinSessionAsync(args, sender); if (joinSessionResult.Status == AllJoynStatus.Ok) { DisposeConsumer(); m_consumer = joinSessionResult.Consumer; m_consumer.SessionLost += Consumer_SessionLost; if (!m_isCredentialsRequested) { GetOnboardeeNetworkListAsync(); } else { if (m_isAuthenticated) { GetOnboardeeNetworkListAsync(); } } } else { UpdateStatusAsync(string.Format("Attempt to join session failed with AllJoyn error: 0x{0:X}.", joinSessionResult.Status), NotifyType.ErrorMessage); } }