/// <summary>
 /// Create a new node library manager.
 /// </summary>
 /// <param name="libraryPath">Path to the libraries folder</param>
 public NodeLibraryManager(string libraryPath, HostClient clientInterface)
 {
     this.clientInterface = clientInterface;
     if (!Directory.Exists(libraryPath)) Directory.CreateDirectory(libraryPath);
     this.libraryPath = libraryPath;
     Instance = this;
 }
示例#2
0
        public static void Main(string[] args)
        {
            running = true;
            log4net.Config.XmlConfigurator.Configure();
            log.Info("=== Matrix Host Server Launching ===");

            log.Debug("Searching for encryption key "+Settings.Default.KeyFile+"...");
            if(!File.Exists(Settings.Default.KeyFile))
            {
                log.Error("No encryption key! Exiting...");
                Console.ReadLine();
                return;
            }

            byte[] hash;
            AES encrypt;
            //Hash the file to a all lowercase string
            using (var md5 = MD5.Create())
            {
                using (var stream = File.OpenRead(Settings.Default.KeyFile))
                {
                    hash = md5.ComputeHash(stream);
                    encrypt = new AES(Encoding.UTF8, Settings.Default.KeyFile);
                }
            }

            client = new HostClient(Settings.Default.MasterIP, Settings.Default.MasterPort, encrypt, hash);
            nodeLibraryManager = new NodeLibraryManager("CompiledNodes", client);
            pool = new NodePool();
            client.Startup();

            while(running)
            {
                Thread.Sleep(50);
            }

            client.Shutdown();
            if(restart)
            {
                restart = false;
                Main(args);
            }
        }