Example #1
0
        // GetInternetConnectionStatus() -> nn::nifm::detail::sf::InternetConnectionStatus
        public ResultCode GetInternetConnectionStatus(ServiceCtx context)
        {
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                return(ResultCode.NoInternetConnection);
            }

            InternetConnectionStatus internetConnectionStatus = new InternetConnectionStatus
            {
                Type         = InternetConnectionType.WiFi,
                WifiStrength = 3,
                State        = InternetConnectionState.Connected,
            };

            context.ResponseData.WriteStruct(internetConnectionStatus);

            return(ResultCode.Success);
        }
Example #2
0
        /// <summary>
        ///Bings Login 1 and Login 2 together, and gets the one that is alive out of the two,to connect to
        /// </summary>
        /// <returns>
        /// </returns>
        /// <code>Usage:
        /// Tuple&lt;Uri, Message&gt; = await PingNow(...);
        /// </code>
        public async Task <Tuple <string, string> > PingNow()
        {
            //check if the device has internet Connection on the device
            if (!InternetConnectionStatus.Connected())
            {
                return(new Tuple <string, string>(null, "No Internet Connection"));
            }

            Tuple <string, string> uri = null;

            for (int i = 0; i < 5; i++)
            {
                await new System.Net.NetworkInformation.Ping().SendPingAsync(_login1, 3000)
                .ContinueWith(async(value1) =>
                {
                    if (value1.Status == TaskStatus.RanToCompletion && value1.Result.Status == IPStatus.Success)
                    {
                        uri = new Tuple <string, string>(_login1, "Alive");
                        return(uri);
                    }
                    await new System.Net.NetworkInformation.Ping().SendPingAsync(_login2, 3000)
                    .ContinueWith((value2) =>
                    {
                        if (value2.Result.Status != IPStatus.Success)
                        {
                            return(uri);                                                  // i.e null
                        }
                        //got a success value
                        uri = new Tuple <string, string>(_login2, "Alive");
                        return(uri);
                    });

                    return(uri);
                });

                if (uri != null)
                {
                    break;
                }
            }

            return(uri);
        }
 public InternetConnectionInfo()
 {
     Status = InternetConnectionStatus.unknown;
     ProfileID = NumberOfServices = -1;
     IPAddress = "0.0.0.0";
 }