コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
        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);
            }
        }