Пример #1
0
        private bool InitNetWork()
        {
            //1 初始化程序集
            TypeManager.Instance.Add(DLLType.Common, Assembly.GetAssembly(typeof(TypeManager)));
            TypeManager.Instance.Add(DLLType.Client, Assembly.GetAssembly(this.GetType()));
            //TypeManager.Instance.Add(DLLType.Client, Assembly.GetAssembly(this.GetType()));
            //2 初始化Opcode
            m_opcodeTypeDictionary = new OpcodeTypeDictionary();
            if (!m_opcodeTypeDictionary.Init())
            {
                Log.Error("OpcodeTypeDictionary Initialise  Fail");
                return(false);
            }
            //3 初始化Dispacher
            m_messageDispather = new MessageDispather();
            if (!MessageDispather.Instance.Init())
            {
                Log.Error("MessageDispather Initialise Fail");
                return(false);
            }
            //Log.Info("handler Type  = " + m_messageDispather.Handlers.Keys.First());
            //Log.Info("hander个数:" + m_messageDispather.Handlers.Values.ToList().Count);
            //初始化对象池

            m_objectPool = new ObjectPool();
            //MessageFactory.Adapting(m_objectPool);

            //3 其他配置

            return(true);
        }
Пример #2
0
        /// <summary>
        /// 用来初始化两个组件
        /// </summary>
        /// <returns></returns>
        protected virtual bool InitlizeServerProtobuf()
        {
            MessageDispather = new MessageDispather();
            OpcodeTypeDic    = new OpcodeTypeDictionary();

            if (!OpcodeTypeDic.Init() || !MessageDispather.Init())
            {
                Log.Error("InitlizeServerProtobuf FAIL!!!");
                return(false);
            }

            return(true);
        }