Beispiel #1
0
 internal UserBuffer(int id,
     SessionFactory f,
     Sinan.Collections.BytesSegment r,
     Sinan.Collections.BytesSegment s,
     int sendQueueSize = 64)
 {
     this.factory = f;
     this.BufferID = id;
     this.ReceiveBuffer = r;
     this.SendBuffer = s;
     this.SendPool = new Sinan.Collections.CircularQueue<Sinan.Collections.BytesSegment>(sendQueueSize);
 }
Beispiel #2
0
        /// <summary>
        /// 初始化网络监听
        /// </summary>
        /// <param name="crossdomain"></param>
        private void InitNetFacade(string crossdomain)
        {
            string policy = null;
            try
            {
                if (!string.IsNullOrEmpty(crossdomain))
                {
                    using (FileStream fs = File.OpenRead(crossdomain))
                    using (StreamReader sr = new StreamReader(fs, Encoding.UTF8, false))
                    {
                        policy = sr.ReadToEnd();
                    }
                }
            }
            catch { }

            int maxClient = ConfigLoader.Config.MaxClient;
            int sendQueueSize = ConfigLoader.Config.SendQueueSize;

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

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

            GMProcessor gmProcessor = new GMProcessor(receiveSize);
            SessionFactory gmFactory = new SessionFactory(8, receiveSize, sendSize, 8, gmProcessor);
            gmServer = new AmfServer(gmFactory, gmFactory, hander);
            gmServer.Start(ConfigLoader.Config.EpGM);

            GameProcessor gameProcessor = new GameProcessor(receiveSize);
            SessionFactory gameFactory = new SessionFactory(maxClient, receiveSize, sendSize, sendQueueSize, gameProcessor);
            server = new AmfServer(gameFactory, gameFactory, hander);
            server.Start(ConfigLoader.Config.EpGame);

            Notifier.Instance.Publish(new Notification(GMCommand.GMStart, new object[] { this }), false);
        }