Пример #1
0
 public void ReleaseModule(BusinessModule module)
 {
     if (module != null)
     {
         if (m_mapModules.ContainsKey(module.Name))
         {
             m_mapModules.Remove(module.Name);
             module.Release();
         }
         else
         {
         }
     }
 }
Пример #2
0
        //====================================================
        public ModuleEvent Event(string target, string type)
        {
            ModuleEvent    evt    = null;
            BusinessModule module = GetModule(target);

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

            return(evt);
        }
Пример #3
0
        public BusinessModule CreateModule(string name, object args = null)
        {
            if (m_mapModules.ContainsKey(name))
            {
                return(null);
            }

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

            if (type != null)
            {
                module = Activator.CreateInstance(type) as BusinessModule;
            }
            else
            {
                module = new LuaModule(name);
            }
            m_mapModules.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);
        }
Пример #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   = m_mapCacheMessage[target];
                MessageObject        msgobj = new MessageObject();
                list.Add(msgobj);

                msgobj.target = target;
                msgobj.msg    = msg;
                msgobj.args   = args;
            }
        }