Esempio n. 1
0
 /// <summary>
 /// Constructor takes Server configuration structure which is read from the config file.
 /// </summary>
 /// <param name="ServerConfiguration"></param>
 public Server(ServerInit.ServerSettings ServerConfiguration)
 {
     settings = ServerConfiguration; // the configuration of the server that is being initalzied
 }
Esempio n. 2
0
        /* Creates a directory to store the configuration file and writes the configuration file */
        internal void Add(ServerInit.ServerSettings settings)
        {
            string NewDirectory = ServerDirectory + @"\" + settings.server_name; // EX Servers\myserver\
            Directory.CreateDirectory(NewDirectory);

            List<string> settings_content = new List<string>();
            // build a list that makes the configuration file

            // Example config file:
            //      server #
            //      name
            //      password
            //      backlog
            //      IP
            //      Port

            int ServerNumber = GetServerListCount(); // gives the server a number

            settings_content.Add(ServerNumber.ToString());  // Server #
            settings_content.Add(settings.server_name);     // Name
            settings_content.Add(settings.server_password); // password
            settings_content.Add(settings.backlog.ToString());  // Backlog
            settings_content.Add(settings.server_ip_address);   // IP
            settings_content.Add(settings.port_number.ToString());  //  Port

            string TextFile = settings.server_name + "_Config" + ".txt";
            string ConfigPath = ServerDirectory + @"\" + settings.server_name + @"\";

            ConfigPath = ConfigPath + TextFile;

            Tools.IO.WriteToTextFile(settings_content, ConfigPath);
        }