Exemple #1
0
        public IActorHandler GetHandler(Base.Message.Message msg)
        {
            Type          type = msg.GetType();
            IActorHandler ret  = null;

            mHandler.TryGetValue(type, out ret);
            return(ret);
        }
Exemple #2
0
        public void Awake(ActorHandlerType handlerType)
        {
            switch (handlerType)
            {
            case ActorHandlerType.Gate:
                ActorHandler = new GateActorHandler();
                break;

            case ActorHandlerType.Common:
                ActorHandler = new CommonActorHandler();
                break;
            }
            ActorMessages.Clear();
            AddLocaltion();
        }
Exemple #3
0
 public virtual async void  OnMessage()
 {
     while (true)
     {
         if (mMails.Count > 0)
         {
             Base.Message.Message m = mMails.Dequeue();
             await Task.Run(() =>
             {
                 Status = STATUS.PROCESSING;
                 IActorHandler handler = ActorDispacher.Instance.GetHandler(m);
                 if (null != handler)
                 {
                     handler.Handle(m);
                 }
             });
         }
         else
         {
             break;
         }
     }
 }
Exemple #4
0
 public void Awake()
 {
     ActorHandler = new CommonActorHandler();
     ActorMessages.Clear();
     AddLocaltion();
 }
Exemple #5
0
        public void AddHandler(Type msgType, Type handlerType)
        {
            IActorHandler handler = (IActorHandler)System.Activator.CreateInstance(handlerType);

            mHandler[msgType] = handler;
        }