Ejemplo n.º 1
0
 public void ReleaseModule(BusinessModule module)
 {
     if (module != null)
     {
         m_mapMdules.ContainsKey(module.Name);
         m_mapMdules.Remove(module.Name);
         module.Release();
     }
     else
     {
     }
 }
Ejemplo n.º 2
0
        public BusinessModule CreateModule(string name, object args = null)
        {
            if (m_mapMdules.ContainsKey(name))
            {
                return(m_mapMdules[name]);
            }

            BusinessModule module = null;
            Type           type   = Type.GetType(m_domain + "." + name);

            if (type != null)
            {
                module = Activator.CreateInstance(type) as BusinessModule;
            }
            else
            {
                //module = new LuaModule(name);
                return(null);
            }

            m_mapMdules.Add(name, module);

            //处理预监听的事件
            if (m_mapPreListenEvents.ContainsKey(name))
            {
                EventTable tblEvent = m_mapPreListenEvents[name];
                m_mapPreListenEvents.Remove(name);

                module.SetEventTable(tblEvent);
            }

            module.Create(args);

            //处理缓存的消息
            if (m_mapCacheMessage.ContainsKey(name))
            {
                List <MessageObject> list = m_mapCacheMessage[name];
                for (int i = 0; i < list.Count; i++)
                {
                    MessageObject msgObj = list[i];
                    module.HandleMessage(msgObj.msg, msgObj.args);
                }
                m_mapCacheMessage.Remove(name);
            }

            return(module);
        }
Ejemplo n.º 3
0
        //----------------------------------------------------------

        public ModuleEvent Event(string target, string type)
        {
            ModuleEvent    evt    = null;
            BusinessModule module = GetModule(target);

            if (module != null)
            {
                evt = module.Event(type);
            }
            else
            {
                EventTable table = GetPreListenEventTable(target);
                evt = table.GetEvent(type);
            }

            return(evt);
        }
Ejemplo n.º 4
0
        //-----------------------------------------------------

        public void SendMessage(string target, string msg, params object[] args)
        {
            BusinessModule module = GetModule(target);

            if (module != null)
            {
                module.HandleMessage(msg, args);
            }
            else
            {
                //模块还未创建,将消息缓存
                List <MessageObject> list   = GetCacheMessageList(target);
                MessageObject        msgObj = new MessageObject();
                list.Add(msgObj);

                msgObj.target = target;
                msgObj.msg    = msg;
                msgObj.args   = args;
            }
        }