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); } }
private async void Watcher_Added(DeviceWatcher sender, DeviceInformation 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; } DisposeConsumer(); UpdateStatusAsync("Joining session...", NotifyType.StatusMessage); m_consumer = await OnboardingConsumer.FromIdAsync(args.Id, m_busAttachment); if (m_consumer != null) { m_consumer.Session.Lost += Consumer_SessionLost; GetOnboardeeNetworkListAsync(); } else { UpdateStatusAsync("Attempt to join session failed.", NotifyType.ErrorMessage); } }
private void DisposeConsumer() { if (m_consumer != null) { m_consumer.SessionLost -= Consumer_SessionLost; m_consumer.Dispose(); m_consumer = null; } }
private void DisposeConsumer() { if (m_consumer != null) { m_consumer.SessionLost -= Consumer_SessionLost; m_consumer.Dispose(); m_consumer = null; } }
private void Consumer_SessionLost(OnboardingConsumer sender, AllJoynSessionLostEventArgs args) { UpdateStatusAsync(string.Format("AllJoyn session with the onboardee lost due to {0}.", args.Reason.ToString()), NotifyType.StatusMessage); DisposeConsumer(); ResetControls(); }
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 Consumer_SessionLost(OnboardingConsumer sender, AllJoynSessionLostEventArgs args) { UpdateStatusAsync(string.Format("AllJoyn session with the onboardee lost due to {0}.", args.Reason.ToString()), NotifyType.StatusMessage); DisposeConsumer(); ResetControls(); }
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(DeviceWatcher sender, DeviceInformation 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; } DisposeConsumer(); UpdateStatusAsync("Joining session...", NotifyType.StatusMessage); m_consumer = await OnboardingConsumer.FromIdAsync(args.Id, m_busAttachment); if (m_consumer != null) { m_consumer.Session.Lost += Consumer_SessionLost; GetOnboardeeNetworkListAsync(); } else { UpdateStatusAsync("Attempt to join session failed.", NotifyType.ErrorMessage); } }