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); } }
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 void DisposeWatcher() { if (m_watcher != null) { m_watcher.Added -= Watcher_Added; m_watcher.Stop(); m_watcher.Dispose(); m_watcher = null; } }
private void ScanForOnboardingInterfaces() { m_busAttachment = new AllJoynBusAttachment(); m_busAttachment.StateChanged += BusAttachment_StateChanged; m_busAttachment.AuthenticationMechanisms.Clear(); m_busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.EcdhePsk); m_busAttachment.AuthenticationComplete += BusAttachment_AuthenticationComplete; m_busAttachment.CredentialsRequested += BusAttachment_CredentialsRequested; m_watcher = new OnboardingWatcher(m_busAttachment); m_watcher.Added += Watcher_Added; UpdateStatusAsync("Searching for onboarding interface...", NotifyType.StatusMessage); m_watcher.Start(); }
private void ScanForOnboardingInterfaces() { ScenarioCleanup(); // Allow re-joining of a new session Interlocked.Exchange(ref m_onboardSessionAlreadyJoined, 0); m_busAttachment = new AllJoynBusAttachment(); m_busAttachment.StateChanged += BusAttachment_StateChanged; m_busAttachment.AuthenticationMechanisms.Clear(); // EcdhePsk authentication is deprecated as of the AllJoyn 16.04 release. // Newly added EcdheSpeke should be used instead. EcdhePsk authentication is // added here to maintain compatibility with devices running older AllJoyn versions. m_busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.EcdheNull); m_busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.EcdhePsk); m_busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.EcdheSpeke); m_busAttachment.AuthenticationComplete += BusAttachment_AuthenticationComplete; m_busAttachment.CredentialsRequested += BusAttachment_CredentialsRequested; m_watcher = new OnboardingWatcher(m_busAttachment); m_watcher.Added += Watcher_Added; UpdateStatusAsync("Searching for onboarding interface...", NotifyType.StatusMessage); m_watcher.Start(); }
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 || m_isAuthenticated) { GetOnboardeeNetworkListAsync(); } } else { UpdateStatusAsync(string.Format("Attempt to join session failed with AllJoyn error: 0x{0:X}.", joinSessionResult.Status), NotifyType.ErrorMessage); } }
private void ScanForOnboardingInterfaces() { ScenarioCleanup(); m_busAttachment = new AllJoynBusAttachment(); m_busAttachment.StateChanged += BusAttachment_StateChanged; m_busAttachment.AuthenticationMechanisms.Clear(); m_busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.EcdhePsk); m_busAttachment.AuthenticationComplete += BusAttachment_AuthenticationComplete; m_busAttachment.CredentialsRequested += BusAttachment_CredentialsRequested; m_watcher = new OnboardingWatcher(m_busAttachment); m_watcher.Added += Watcher_Added; UpdateStatusAsync("Searching for onboarding interface...", NotifyType.StatusMessage); m_watcher.Start(); }