Пример #1
0
        public static void Main(string[] args)
        {
            string netconfig;

            // Read network config
            if (FileManager.ReadFile(".config", out netconfig))
            {
                var config = netconfig.Split(':');
                HOST = config[0];

                if (config.Length > 1)
                {
                    PORT = int.Parse(config[1]);
                }
            }

            // Load directory into a bundle, using ints for this example because no one wants to type GUID's
            bundles = new List <BundleResponse>();

            if (bundles.Contains(null))
            {
                Console.WriteLine("One or more asset directories do not exist. Exiting..");
                Console.ReadLine();
                return;
            }

            Server server = new Server
            {
                Services = { Bundle.BindService(new BundleImpl(bundles)), Asset.BindService(new AssetImpl()) },
                Ports    = { new ServerPort(HOST, PORT, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("Server listening on port " + PORT);

            while (true)
            {
                Console.Write("Enter a bundle (ID,path): ");

                string bundleToLoad = Console.ReadLine();
                if (bundleToLoad.ToLower() == "exit")
                {
                    break;
                }
                else
                {
                    loadBundle(bundleToLoad);
                }
            }

            server.ShutdownAsync().Wait();
        }