public bool Start()
        {
            bool isSuccess = application.Start();

            clearRequestCommands();
            bool isRunning = (application.ServerList.First() as AsyncTcpServer).IsRunning;

            if (isRunning)
            {
                if (ServerOpened != null)
                {
                    ServerOpened(this, EventArgs.Empty);
                }
            }
            else
            {
                ThreadPool.QueueUserWorkItem(new WaitCallback((o) =>
                {
                    Thread.Sleep(2000);
                    if (IsRunning)
                    {
                        if (ServerOpened != null)
                        {
                            ServerOpened(this, EventArgs.Empty);
                        }
                    }
                }), null);
            }

            return(isRunning);
        }
Esempio n. 2
0
 public void HandleRequest()
 {
     try {
         Request  request  = ReadMessage();
         Response response = Process(request);
         SendMessage(response);
         webSocketApplication?.Start();
     } catch (SocketException ioe) {
         SendMessage(new HttpResponse("", DateTime.Now, HttpStatusCode.ServerError));
         Console.WriteLine("[DEBUG] Error: " + ioe.ToString());
     } finally {
         socket.Close();
     }
 }