コード例 #1
0
        private static async void HandleAsync(this ActorComponent self)
        {
            while (true)
            {
                if (self.IsDisposed)
                {
                    return;
                }
                try
                {
                    ActorMessageInfo info = await self.GetAsync();

                    // 返回null表示actor已经删除,协程要终止
                    if (info == null)
                    {
                        return;
                    }
                    await self.entityActorHandler.Handle(info.Session, (Entity)self.Parent, info.RpcId, info.Message);
                }
                catch (Exception e)
                {
                    Log.Error(e.ToString());
                }
            }
        }
コード例 #2
0
        public static async void HandleAsync(this ActorComponent self)
        {
            ActorMessageDispatherComponent actorMessageDispatherComponent = Game.Scene.GetComponent <ActorMessageDispatherComponent>();

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

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

                    // 根据这个actor的类型分发给相应的ActorHandler处理
                    await actorMessageDispatherComponent.ActorTypeHandle(self.ActorType, (Entity)self.Parent, info);
                }
                catch (Exception e)
                {
                    Log.Error(e);
                }
            }
        }
コード例 #3
0
ファイル: ActorSystem.cs プロジェクト: wang10998588/Egametang
		private static async void HandleAsync(this ActorComponent self)
		{
			while (true)
			{
				try
				{
					ActorMessageInfo info = await self.GetAsync();
					await self.entityActorHandler.Handle(info.Session, self.Entity, info.Message);
				}
				catch (Exception e)
				{
					Log.Error(e.ToString());
				}
			}
		}