Exemplo n.º 1
0
        public static async Task StartAsync(int port)
        {
            IPAddress localAddr = await EndpointUtils.GetIPAsync();

            IExpiryProvider expiryProvider = new StorageExpiryProvider();
            IStorage        storage        = new InMemoryStorage(expiryProvider);

            IRequestProcessor requestProcessor = new RequestProcessor(storage);
            IProcessor        processor        = new SocketProcessor();
            IListener         server           = new Listener(localAddr, port, processor, requestProcessor);

            server.Start();

            var reset = new ManualResetEventSlim();

            Console.CancelKeyPress += (sender, e) =>
            {
                reset.Set();
            };

            reset.Wait();

            // dispose components
            storage.Dispose();
            server.Dispose();
        }
Exemplo n.º 2
0
        public static void Start(SettingsArgs settings, LoggingConfiguration config)
        {
            LogManager.Configuration = config;


            IStorage storage = new InMemoryStorage();

            IRequestProcessor requestProcessor = new RequestProcessor(storage);
            ISocketProcessor  processor        = new SocketProcessor();
            IListener         server           = new Listener(settings, processor, requestProcessor);

            server.Start();
            IsWorking = true;

            Console.CancelKeyPress += (sender, args) => Stop();

            _cancelEvent.Wait();
            _cancelEvent.Reset();

            // dispose components
            storage.Dispose();
            server.Dispose();
        }