Example #1
0
        /// <summary>
        /// 初始化网络监听
        /// </summary>
        /// <param name="path"></param>
        private void InitNetFacade(string path)
        {
            string policy = null;
            try
            {
                using (FileStream fs = File.OpenRead(Path.Combine(path, "crossdomain.txt")))
                using (StreamReader sr = new StreamReader(fs, Encoding.UTF8, false))
                {
                    policy = sr.ReadToEnd();
                }
            }
            catch { }

            GMManager.Instance.Load(Path.Combine(path, "GMList.txt"));
            FrontManager.Instance.Load(Path.Combine(path, "FrontIP.txt"));

            AmfStringZip zip = new CommandMap();
            zip.Load(Path.Combine(path, "Command.txt"));

            string ip = "0.0.0.0";
            string ports = "8005";
            int maxClient = 1000;
            int maxWaitSend = 64;

            const int receiveSize = 8 * 1024;
            const int sendSize = 64 * 1024;

            AmfCodec.Init(maxClient, zip);
            IHandshake hander = new Handshaker(policy);

            CommandProcessor gameProcessor = new CommandProcessor(receiveSize, zip);
            SessionFactory gameFactory = new SessionFactory(receiveSize, sendSize, maxWaitSend, gameProcessor);
            server = new GMService(gameFactory, gameFactory, hander);
            server.Start(ip, ports.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries));
        }