public async Task Handle(Session session, Entity entity, ActorRequest message) { Message msg = message.AMessage as Message; if (msg == null) { Log.Error($"消息类型转换错误: {message.GetType().FullName} to {typeof (Message).Name}"); return; } E e = entity as E; if (e == null) { Log.Error($"Actor类型转换错误: {entity.GetType().Name} to {typeof(E).Name}"); return; } await this.Run(e, msg); // 等回调回来,session可以已经断开了,所以需要判断session id是否为0 if (session.Id == 0) { return; } ActorResponse response = new ActorResponse { RpcId = message.RpcId }; session.Reply(response); }
public async Task Handle(Session session, Entity entity, uint rpcId, ActorRequest message) { try { Request request = message.AMessage as Request; if (request == null) { Log.Error($"消息类型转换错误: {message.GetType().FullName} to {typeof (Request).Name}"); return; } E e = entity as E; if (e == null) { Log.Error($"Actor类型转换错误: {entity.GetType().Name} to {typeof(E).Name}"); return; } await this.Run(e, request, response => { // 等回调回来,session可以已经断开了,所以需要判断session id是否为0 if (session.Id == 0) { return; } ActorResponse actorResponse = new ActorResponse { AMessage = response }; session.Reply(rpcId, actorResponse); }); } catch (Exception e) { throw new Exception($"解释消息失败: {message.GetType().FullName}", e); } }
public async Task<bool> Handle(Session session, Entity entity, ActorRequest message) { ((Session)entity).Send(message.AMessage); ActorResponse response = new ActorResponse(); response.RpcId = message.RpcId; session.Reply(response); return true; }
public async Task Handle(Session session, Entity entity, ActorRequest message) { if (!this.handlers.TryGetValue(message.AMessage.GetType(), out IMActorHandler handler)) { throw new Exception($"not found message handler: {MongoHelper.ToJson(message)}"); } await handler.Handle(session, entity, message); }
public override async Task <AResponse> Run() { ActorRequest request = new ActorRequest() { Id = this.proxy.Id, AMessage = this.message }; ActorResponse response = await this.proxy.RealCall <ActorResponse>(request, this.proxy.CancellationTokenSource.Token); return(response); }
public async Task Handle(Session session, Entity entity, ActorRequest message) { ((Session)entity).Send(message.AMessage); ActorResponse response = new ActorResponse { RpcId = message.RpcId }; session.Reply(response); }
public async Task <bool> Handle(Session session, Entity entity, ActorRequest message) { if (!this.handlers.TryGetValue(message.AMessage.GetType(), out IMActorHandler handler)) { Log.Error($"not found message handler: {message.GetType().FullName}"); return(false); } return(await handler.Handle(session, entity, message)); }
public override async Task <AResponse> Run() { ActorRequest request = new ActorRequest() { Id = this.proxy.Id, AMessage = this.message }; Response response = await this.proxy.RealCall <Response>(request, this.proxy.CancellationTokenSource.Token); if (response.Error != ErrorCode.ERR_NotFoundActor) { this.Tcs.SetResult(response); } return(response); }
public async Task <IResponse> Run() { ActorRequest request = new ActorRequest() { Id = this.proxy.Id, AMessage = this.message }; ActorResponse response = (ActorResponse)await this.proxy.RealCall(request, this.proxy.CancellationTokenSource.Token); if (response.Error != ErrorCode.ERR_NotFoundActor) { this.Tcs?.SetResult((IResponse)response.AMessage); } return(response); }
public async Task <Response> RealCall <Response>(ActorRequest request, CancellationToken cancellationToken) where Response : AResponse { try { //Log.Debug($"realcall {MongoHelper.ToJson(request)} {this.Address}"); request.Id = this.Id; Session session = Game.Scene.GetComponent <NetInnerComponent>().Get(this.Address); Response response = await session.Call <Response>(request, cancellationToken); return(response); } catch (RpcException e) { Log.Error($"{this.Address} {e}"); throw; } }
public async Task<bool> Handle(Session session, Entity entity, ActorRequest message) { return await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message); }
public async Task <bool> Handle(Session session, Entity entity, ActorRequest message) { ((Session)entity).Send(message.AMessage); return(true); }