private async void Watcher_Added(SecureInterfaceWatcher sender, AllJoynServiceInfo args) { UpdateStatus("Connecting...", NotifyType.StatusMessage); // Attempt to join the session when a producer is discovered. SecureInterfaceJoinSessionResult joinSessionResult = await SecureInterfaceConsumer.JoinSessionAsync(args, sender); if (joinSessionResult.Status == AllJoynStatus.Ok) { m_consumer = joinSessionResult.Consumer; isConnected = true; // At the time of connection, the request credentials callback not being invoked is an // indication that the client and server are already authenticated from a previous session. if (!isCredentialsRequested) { UpdateStatus("Connected and already authenticated from previous session.", NotifyType.StatusMessage); } else { if (isAuthenticated) { UpdateStatus("Connected with authentication.", NotifyType.StatusMessage); } else { UpdateStatus("Connected but authentication failed.", NotifyType.ErrorMessage); } } } else { UpdateStatus(String.Format("Attempt to connect 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 async void Watcher_Added(SecureInterfaceWatcher sender, AllJoynServiceInfo args) { // Optional - Get the About data of the producer. AllJoynAboutDataView aboutData = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, m_busAttachment, args.SessionPort); // Check to see if device name is populated in the about data, since device name is not a mandatory field. if (string.IsNullOrEmpty(aboutData.DeviceName)) { UpdateStatusAsync(string.Format("Found {0} from manufacturer: {1}. Connecting...", aboutData.AppName, aboutData.Manufacturer), NotifyType.StatusMessage); } else { UpdateStatusAsync(string.Format("Found {0} on {1} from manufacturer: {2}. Connecting...", aboutData.AppName, aboutData.DeviceName, aboutData.Manufacturer), NotifyType.StatusMessage); } // Attempt to join the session when a producer is discovered. SecureInterfaceJoinSessionResult joinSessionResult = await SecureInterfaceConsumer.JoinSessionAsync(args, sender); if (joinSessionResult.Status == AllJoynStatus.Ok) { DisposeConsumer(); m_consumer = joinSessionResult.Consumer; m_consumer.IsUpperCaseEnabledChanged += Consumer_IsUpperCaseEnabledChanged; m_consumer.Signals.TextSentReceived += Signals_TextSentReceived; m_consumer.SessionLost += Consumer_SessionLost; // At the time of connection, the request credentials callback not being invoked is an // indication that the consumer and producer are already authenticated from a previous session. if (!m_isCredentialsRequested) { UpdateStatusAsync("Connected and already authenticated from previous session.", NotifyType.StatusMessage); UpdateIsUpperCaseEnabledAsync(); } else { if (m_isAuthenticated) { UpdateStatusAsync("Connected with authentication.", NotifyType.StatusMessage); UpdateIsUpperCaseEnabledAsync(); } else { UpdateStatusAsync("Connected but authentication failed.", NotifyType.ErrorMessage); } } ConsumerOptionsVisibility = Visibility.Visible; } else { UpdateStatusAsync(string.Format("Attempt to connect failed with AllJoyn error: 0x{0:X}.", joinSessionResult.Status), NotifyType.ErrorMessage); } }
private async void Watcher_Added(SecureInterfaceWatcher sender, AllJoynServiceInfo args) { // Attempt to join the session when a producer is discovered. SecureInterfaceJoinSessionResult joinSessionResult = await SecureInterfaceConsumer.JoinSessionAsync(args, sender); if (joinSessionResult.Status == AllJoynStatus.Ok) { m_consumer = joinSessionResult.Consumer; isConnected = true; UpdateStatus("Connected.", NotifyType.StatusMessage); } else { UpdateStatus(String.Format("Attempt to connect failed with error: {0}", joinSessionResult.Status), NotifyType.ErrorMessage); } }
public void Start() { UpdateStatus("Connecting...", NotifyType.StatusMessage); // Create a new AllJoyn bus attachment. AllJoynBusAttachment busAttachment = new AllJoynBusAttachment(); // Initialize a watcher object to listen for about interfaces. SecureInterfaceWatcher watcher = new SecureInterfaceWatcher(busAttachment); // Subscribing to the added event that will fire whenever a producer for this service is found. watcher.Added += Watcher_Added; // Start watching for producers advertising this service. watcher.Start(); }
public void Start() { AllJoynBusAttachment busAttachment = new AllJoynBusAttachment(); busAttachment.AuthenticationMechanisms.Clear(); busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.EcdhePsk); busAttachment.AuthenticationComplete += BusAttachment_AuthenticationComplete; busAttachment.CredentialsRequested += BusAttachment_CredentialsRequested; // Initialize a watcher object to listen for about interfaces. SecureInterfaceWatcher watcher = new SecureInterfaceWatcher(busAttachment); // Subscribing to the added event that will be raised whenever a producer for this service is found. watcher.Added += Watcher_Added; UpdateStatus("Searching...", NotifyType.StatusMessage); // Start watching for producers advertising this service. watcher.Start(); }
private async void Watcher_Added(SecureInterfaceWatcher sender, AllJoynServiceInfo args) { UpdateStatusAsync("Connecting...", NotifyType.StatusMessage); // Attempt to join the session when a producer is discovered. SecureInterfaceJoinSessionResult joinSessionResult = await SecureInterfaceConsumer.JoinSessionAsync(args, sender); if (joinSessionResult.Status == AllJoynStatus.Ok) { DisposeConsumer(); m_consumer = joinSessionResult.Consumer; m_consumer.IsUpperCaseEnabledChanged += Consumer_IsUpperCaseEnabledChanged; m_consumer.Signals.TextSentReceived += Signals_TextSentReceived; m_consumer.SessionLost += Consumer_SessionLost; // At the time of connection, the request credentials callback not being invoked is an // indication that the client and server are already authenticated from a previous session. if (!m_isCredentialsRequested) { UpdateStatusAsync("Connected and already authenticated from previous session.", NotifyType.StatusMessage); UpdateIsUpperCaseEnabledAsync(); } else { if (m_isAuthenticated) { UpdateStatusAsync("Connected with authentication.", NotifyType.StatusMessage); UpdateIsUpperCaseEnabledAsync(); } else { UpdateStatusAsync("Connected but authentication failed.", NotifyType.ErrorMessage); } } ClientOptionsVisibility = Visibility.Visible; } else { UpdateStatusAsync(string.Format("Attempt to connect failed with AllJoyn error: 0x{0:X}.", joinSessionResult.Status), NotifyType.ErrorMessage); } }
private void Start() { ScenarioCleanup(); m_busAttachment = new AllJoynBusAttachment(); m_busAttachment.StateChanged += BusAttachment_StateChanged; m_busAttachment.AuthenticationMechanisms.Clear(); m_busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.EcdheSpeke); m_busAttachment.AuthenticationComplete += BusAttachment_AuthenticationComplete; m_busAttachment.CredentialsRequested += BusAttachment_CredentialsRequested; // Initialize a watcher object to listen for about interfaces. m_watcher = new SecureInterfaceWatcher(m_busAttachment); // Subscribing to the added event that will be raised whenever a producer for this service is found. m_watcher.Added += Watcher_Added; UpdateStatusAsync("Searching...", NotifyType.StatusMessage); // Start watching for producers advertising this service. m_watcher.Start(); }
private void Start() { 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; // Initialize a watcher object to listen for about interfaces. m_watcher = new SecureInterfaceWatcher(m_busAttachment); // Subscribing to the added event that will be raised whenever a producer for this service is found. m_watcher.Added += Watcher_Added; UpdateStatusAsync("Searching...", NotifyType.StatusMessage); // Start watching for producers advertising this service. m_watcher.Start(); }