Ejemplo n.º 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            IServerRequestHandler  requestHandler  = new ServerRequestHandler();
            IServerResponseHandler responseHandler = new ServerResponseHandler();


            IContainerInterfaces containerInterfaces = new ContainerInterfaces(requestHandler, responseHandler, _logger);
            ServerSocket         serverSocket        = new ServerSocket(11111, containerInterfaces);

            serverSocket.Listen();
        }
Ejemplo n.º 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="serverEndPoint"></param>
 /// <param name="configurationWatcher"></param>
 public ConfigFileServer(EndPoint serverEndPoint, ConfigurationWatcher configurationWatcher)
 {
     this.sessions       = new Dictionary <ulong, KeyValuePair <string, Encoding> >();
     this.requestHandler = new ServerRequestHandler(serverEndPoint, this, new Protocol());
     this.requestHandler.OnMessageReceived  += this.RequestHandler_OnMessageReceived;
     this.requestHandler.OnConnectionClosed += this.RequestHandler_OnConnectionClosed;
     this.configurationWatcher = configurationWatcher;
     this.configurationWatcher.OnAppFileChanged   += this.ConfigurationWatcher_OnAppFileChanged;
     this.configurationWatcher.OnAppFileDeleted   += this.ConfigurationWatcher_OnAppFileDeleted;
     this.configurationWatcher.OnAppFileRenamed   += this.ConfigurationWatcher_OnAppFileRenamed;
     this.configurationWatcher.OnShareFileChanged += this.ConfigurationWatcher_OnShareFileChanged;
     this.configurationWatcher.OnShareFileDeleted += this.ConfigurationWatcher_OnShareFileDeleted;
     this.configurationWatcher.OnShareFileRenamed += this.ConfigurationWatcher_OnShareFileRenamed;
 }
Ejemplo n.º 3
0
        private IWebHostBuilder CreateWebHostBuilder(ILoggerFactory loggerFactory)
        {
            return(new WebHostBuilder()
                   .ConfigureServices(services =>
            {
                services.Replace(ServiceDescriptor.Singleton(loggerFactory ?? new NullLoggerFactory()));
                services.AddSingleton(Handler);
                services.AddTransient <ServerRequestHandler>();
            })
                   .UseKestrel(options => options.AddServerHeader = false)
                   .CaptureStartupErrors(false)
                   .SuppressStatusMessages(true)
                   .Configure(applicationBuilder =>
            {
                _configureAppBuilder?.Invoke(applicationBuilder);

                AddMockHttpServerHeader(applicationBuilder);

                ServerRequestHandler serverRequestHandler = applicationBuilder.ApplicationServices.GetRequiredService <ServerRequestHandler>();
                applicationBuilder.Use(serverRequestHandler.HandleAsync);
            }));
        }