Exemple #1
0
        static async Task Main(string[] args)
        {
            Console.WriteLine(Environment.CurrentDirectory);

            var jsonData = ReadJson("scriptPaths.json");

            await jsonData.ToAsync().MatchAsync(
                Right: async json =>
            {
                var keyScriptJsonMap = new KeyScriptJsonMap(json);
                var responseMaker    = new ResponseMaker(keyScriptJsonMap);

                while (true)
                {
                    Console.WriteLine("Enter rquest topic. If you want to quit this app, press 'quit'.");
                    Console.Write("Enter here : ");

                    var input = Console.ReadLine();

                    if (input == "quit")
                    {
                        break;
                    }

                    var ret = await responseMaker.MakeResponseAsync(input, MakeRequest());

                    ret.Match(
                        Right: x =>
                    {
                        Console.WriteLine(x.requestProto.ToJsonString());
                        Console.WriteLine(x.responseProto.ToJsonString());
                    },
                        Left: x =>
                    {
                        Console.WriteLine(x);
                    });
                }
            },
                LeftAsync: ex =>
            {
                Console.WriteLine(ex);
                Console.ReadKey();
                return(Task.CompletedTask);
            });
        }
        public void Start(string ip, UInt16 port, uint readBufferSize, uint timeout, X509Certificate2 certificate, HttpRequestProcessor httpRequestHandler, ResponseMaker internalServerError, LogManager logger)
        {
            if (ConnectionAcceptor == null)
            {
                ConnectionAcceptor = new TcpListener(IPAddress.Parse(ip), port);
            }

            if (Sessions == null)
            {
                Sessions = new ConcurrentDictionary <ulong, Session>();
            }

            this.ReadBufferSize         = readBufferSize;
            this.Timeout                = timeout;
            this.HttpRequestHandler     = httpRequestHandler;
            this.GetInternalServerError = internalServerError;
            this.Certificate            = certificate;
            this.Logger = logger;

            ConnectionAcceptor.Start();
            ConnectionAcceptor.BeginAcceptTcpClient(new AsyncCallback(OnAccept), this.ConnectionAcceptor);
        }
 public void Start(string ip, UInt16 port, uint readBufferSize, uint timeout, HttpRequestProcessor httpRequestHandler, ResponseMaker internalServerError, LogManager logger)
 {
     this.Start(ip, port, readBufferSize, timeout, null, httpRequestHandler, internalServerError, logger);
 }