Ejemplo n.º 1
0
 public ServerManager(int port, IServerValidator validator, IFeedback fb)
 {
     _msgcnt      = 0;
     _timeout     = TimeSpan.FromSeconds(10);
     _webrequests = new List <Dtos.WebRequest>();
     _feedback    = fb ?? throw new NullReferenceException("No feedback provided");
     _validator   = validator ?? throw new NullReferenceException("No validator provided");
     _clients     = new ConcurrentDictionary <Guid, ServerClient>();
     _thread      = new Thread(Process);
     _listener    = new TcpListener(new IPEndPoint(IPAddress.Any, port));
     _alive       = true;
     _listener.Start();
     _thread.Start();
 }
Ejemplo n.º 2
0
        public ServerBuilder(AbstractServerConfiguration configuration, IServerValidator validator)
        {
            if (!configuration.IsValid())
            {
                throw new Exception("Cannot create a server from an invalid configuration.");
            }

            Configuration = configuration;
            Server        = new Server
            {
                Name = configuration.ServerName
            };
            Validator = validator;

            Server.SetConfiguration(Configuration);
        }