Exemple #1
0
        static void Main()
        {
            WebServerLog.LogAdded += WebServerLog_LogAdded;
            var server = new Server(new WebServerSettings(8000, 5000));

            // add services
            server.AddWebService(new HttpRequestParser());
            server.AddWebService(new HttpHeaderPostParser());
            server.AddWebService(new HttpHeaderSpecialAction());
            server.AddWebService(new HttpResponseCreator());
            server.AddWebService(new HttpSender());
            // setup web socket
            var websocket = new WebSocketService();

            websocket.Add(new EchoEndpoint());
            server.AddWebService(websocket);
            // start server
            server.Start();
            // wait for console quit
            while (Console.ReadKey().Key != ConsoleKey.Q)
            {
                ;
            }
            // close
            server.Stop();
            websocket.Dispose();
        }
        static void Main()
        {
            var server = new Server(new WebServerSettings(8002, 5000));

            server.AddWebService(new HttpRequestParser());
            server.AddWebService(new HttpHeaderSpecialAction());
            server.AddWebService(new Http404Service());
            server.AddWebService(new HttpResponseCreator());
            server.AddWebService(new HttpSender());
            server.AddWebService(new TaskGame.SpecialFileService());

            var searcher = new HttpDocumentFinder();

            if (System.Diagnostics.Debugger.IsAttached)
            {
                searcher.Add(new HttpDocumentFinder.Rule("/content/", "../../../content/", false, true));
            }
            else
            {
                searcher.Add(new HttpDocumentFinder.Rule("/content/", "content/", false, true));
            }
            server.AddWebService(searcher);
            server.AddWebService(new HttpDirectoryMapper(false));

            using var webSocket = new WebSocketService();
            webSocket.Add(new TaskGame.GameEndpoint());
            server.AddWebService(webSocket);

            server.Start();

            while (Console.ReadKey().Key != ConsoleKey.Q)
            {
                ;
            }

            server.Stop();
        }