Exemple #1
0
        static async Task Main(string[] args)
        {
            if (args.Length != 2)
            {
                Console.WriteLine("usage: mobilehotspot.exe SSID PASSPHRASE");
                return;
            }

            var cancellationTokenSource = new CancellationTokenSource();

            var hotspot = await HotspotManager.CreateAsync(args[0], args[1]);

            hotspot.ClientConnected    += (_, clientInfo) => Console.WriteLine($"CON | {ToString(clientInfo)}");
            hotspot.ClientDisconnected += (_, clientInfo) => Console.WriteLine($"DIS | {ToString(clientInfo)}");

            Console.Error.WriteLine("Starting hotspot ... press \"q\" and Enter to quit");

            var hotspotTask = hotspot.RunAsync(cancellationTokenSource.Token);

            // wait for 'q'
            while (Convert.ToChar(Console.Read()) != 'q')
            {
                ;
            }

            Console.Error.WriteLine("Stopping hotspot ...");
            cancellationTokenSource.Cancel();
            hotspotTask.GetAwaiter().GetResult();
        }
Exemple #2
0
        /// <summary>
        /// Creates a new HotspotManager with the given connection profile and configuration.
        /// </summary>
        public static async Task <HotspotManager> CreateAsync(ConnectionProfile profile, NetworkOperatorTetheringAccessPointConfiguration configuration)
        {
            var hotspot = new HotspotManager
            {
                tetheringManager = NetworkOperatorTetheringManager.CreateFromConnectionProfile(profile)
            };
            await hotspot.tetheringManager.ConfigureAccessPointAsync(configuration);

            return(hotspot);
        }