Пример #1
0
        public void MicroHttpServer_NoConfigation_returnsError()
        {
            var server = new MicroHttpServer(null);
            var res    = server.Start();

            Assert.IsFalse(res.Success);

            server.Stop();
        }
 protected override void EndWorkerLoop()
 {
     try
     {
         _webServer?.Stop();
         IsWorking = false;
         OnStop();
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, $"Exception caught stopping worker loop [workerId:{_workerId}]");
         Stop();
     }
 }
Пример #3
0
        static void Main(string[] args)
        {
            ArduinoWork.threadHandle(THREAD_MODE.START);
            MicroHttpServer mhs = new MicroHttpServer(1688,
                                                      (req) =>
            {
                string response = "";
                if (req.Url != "/favicon.ico")
                {
                    response = ArduinoWork.SetMode(req.Url);
                    Console.WriteLine(req.Url);
                }
                return
                (new CompactResponse()
                {
                    Data = Encoding.UTF8.GetBytes(response)
                });
            });

            Console.WriteLine("Press any key to stop...");
            Console.Read();
            ArduinoWork.threadHandle(THREAD_MODE.STOP);
            mhs.Stop();
        }