示例#1
0
        public static async ETVoid HandleAsync(this MailBoxComponent self)
        {
            MailboxDispatcherComponent mailboxDispatcherComponent = Game.Scene.GetComponent <MailboxDispatcherComponent>();

            long instanceId = self.InstanceId;

            while (true)
            {
                if (self.InstanceId != instanceId)
                {
                    return;
                }
                try
                {
                    ActorMessageInfo info = await self.GetAsync();

                    // 返回null表示actor已经删除,协程要终止
                    if (info.Message == null)
                    {
                        return;
                    }

                    // 根据这个mailbox类型分发给相应的处理
                    await mailboxDispatcherComponent.Handle(self, info);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
示例#2
0
 public static async ETTask Add(this MailBoxComponent self, Session session, object message)
 {
     //获取到邮箱分发组件 进行处理
     MailboxDispatcherComponent mailboxDispatcherComponent = Game.Scene.GetComponent <MailboxDispatcherComponent>();
     await mailboxDispatcherComponent.Handle(self, session, message);
 }