Example #1
0
 public List <WlanStatusInfo> GetConnectData()
 {
     return(_tetheringManager.GetTetheringClients().Select(item => new WlanStatusInfo()
     {
         Authenticated = true,
         HostName = item.HostNames.FirstOrDefault(x => x.Type == HostNameType.DomainName)?.RawName,
         IpAddress = item.HostNames.FirstOrDefault(x => x.Type == HostNameType.Ipv4)?.RawName,
         MAC = item.MacAddress
     }).ToList());
 }
Example #2
0
        public async Task RunAsync(CancellationToken cancellationToken)
        {
            await tetheringManager.StartTetheringAsync();

            var lastSeenClients = new HashSet <NetworkOperatorTetheringClient>(new ClientComparer());


            while (true)
            {
                // Continuously poll the connected clients
                var currentClients = tetheringManager.GetTetheringClients();

                // Compare with the saved clients to see which are new / which are gone
                var newClients  = currentClients.Except(lastSeenClients, new ClientComparer()).ToArray();
                var goneClients = lastSeenClients.Except(currentClients, new ClientComparer()).ToArray();

                foreach (var client in goneClients)
                {
                    ClientDisconnected?.Invoke(this, client);
                    lastSeenClients.Remove(client);
                }

                foreach (var client in newClients)
                {
                    ClientConnected?.Invoke(this, client);
                    lastSeenClients.Add(client);
                }

                if (cancellationToken.IsCancellationRequested)
                {
                    await tetheringManager.StopTetheringAsync();

                    return;
                }

                await Task.Delay(10000);
            }
        }
Example #3
0
        private void UpdateTetheringStatus()
        {
            switch (tetheringManager.TetheringOperationalState)
            {
            case TetheringOperationalState.InTransition:
//                    txtStatus.Text = "Operation in progress...";
                break;

            case TetheringOperationalState.Off:
                ConfGui_Enable(true);
//                    txtStatus.Text = "Stopped!";
                tgSwitch.IsEnabled = true;
                //                    btnStartStop.Content = "Start";
                tgSwitch.IsOn = false;
                lsClients.Items.Clear();
                break;

            case TetheringOperationalState.On:
                ConfGui_Enable(false);
//                    txtStatus.Text = "Started!";
                tgSwitch.IsEnabled = true;
                //                    btnStartStop.Content = "Stop";
                tgSwitch.IsOn = true;
                lsClients.Items.Clear();
                txtNumConnected.Text = tetheringManager.ClientCount + " " +
                                       Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView().GetString("From") + " " +
                                       tetheringManager.MaxClientCount;
                foreach (var currentClient in tetheringManager.GetTetheringClients())
                {
                    lsClients.Items.Add(currentClient.MacAddress + " " + currentClient.HostNames[1] + " " + currentClient.HostNames[0]);
                }
                break;

            case TetheringOperationalState.Unknown:
//                    txtStatus.Text = "Unknown operation state...";
                break;
            }
        }