/// <summary>
        /// Creates an instance of master service with the specified generator and begins to accept slaves
        /// </summary>
        /// <param name="generator">Class that generates id for user</param>
        public UserServiceMaster(IGenerator generator)
        {
            this.IdGenerator     = generator;
            this.collection      = new List <User>();
            this.formatter       = new BinaryFormatter();
            this.removedServices = new List <TcpClient>();
            this.activeServices  = new List <TcpClient>();

            AppConfigSection config = AppConfigSection.GetConfigSection();

            this.TuneLogger(config);
            this.GetRegisteredServices(config);

            this.listener =
                new TcpListener(new IPEndPoint(IPAddress.Parse(config.MasterEndPoint.Hostname),
                                               int.Parse(config.MasterEndPoint.Port)));
            this.listener.Start();

            ThreadPool.SetMaxThreads(int.Parse(config.ThreadPool.Max), int.Parse(config.ThreadPool.Max));
            ThreadPool.SetMinThreads(int.Parse(config.ThreadPool.Min), int.Parse(config.ThreadPool.Min));

            new Thread(this.Listen)
            {
                IsBackground = true
            }.Start();

            var t = new Timer(this.CheckConnection, null, 600000, 600000);
        }
Example #2
0
        /// <summary>
        /// Creates a new xml storage
        /// </summary>>
        public UserStorageXml()
        {
            AppConfigSection config = AppConfigSection.GetConfigSection();

            this.path = config.FilePath.Value + ".xml";
        }