提交 fd5cb2a2 编写于 作者: T tanghai

gate session转发给client,假如发送失败,需要会给actorproxy一个response

上级 a2750549
using System.Threading.Tasks;
using System;
using System.Threading.Tasks;
using Model;
namespace Hotfix
......@@ -10,12 +11,21 @@ namespace Hotfix
{
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);
ActorResponse response = new ActorResponse { RpcId = message.RpcId };
try
{
((Session)entity).Send(message.AMessage);
session.Reply(response);
await Task.CompletedTask;
}
catch (Exception e)
{
response.Error = ErrorCode.ERR_SessionActorError;
response.Message = $"session actor error {e}";
session.Reply(response);
throw;
}
}
}
......
......@@ -90,10 +90,14 @@ namespace Hotfix
{
while (true)
{
if (self.Id == 0)
{
return;
}
try
{
ActorMessageInfo info = await self.GetAsync();
await self.entityActorHandler.Handle(info.Session, self.Entity, info.Message);
await self.entityActorHandler.Handle(info.Session, self.Entity, info.Message);
}
catch (Exception e)
{
......
......@@ -12,5 +12,7 @@ namespace Model
public const int ERR_ReloadFail = 104;
public const int ERR_NotFoundUnit = 105;
public const int ERR_ActorLocationNotFound = 106;
public const int ERR_SessionActorError = 107;
public const int ERR_ActorError = 108;
}
}
\ No newline at end of file
......@@ -34,6 +34,8 @@ namespace Model
base.Dispose();
this.tcs?.SetException(new Exception($"actor disposed! {this.actorId}"));
Game.Scene.GetComponent<ActorManagerComponent>().Remove(actorId);
}
catch (Exception)
......
......@@ -21,7 +21,7 @@
{
UnityEngine.Debug.Log(msg);
}
public static void Flush()
{
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册