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()); } } }
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); } } }
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()); } } }