合理化框架

合理化框架
This commit is contained in:
ALEXTANG
2023-07-16 15:37:38 +08:00
parent c6ecb48944
commit 7ce72b8aa8
12 changed files with 33 additions and 39 deletions

View File

@@ -2,9 +2,9 @@ namespace TEngine.Core
{
public class CoreErrorCode
{
public const int ErrRpcFail = 100000002; // Rpc消息发送失败
public const int ErrNotFoundRoute = 100000003; // 没有找到Route消息
public const int ErrRouteTimeout = 100000004; // 发送Route消息超时
public const int Error_NotFindEntity = 100000008; // 没有找到Entity
public const uint ErrRpcFail = 100000002; // Rpc消息发送失败
public const uint ErrNotFoundRoute = 100000003; // 没有找到Route消息
public const uint ErrRouteTimeout = 100000004; // 发送Route消息超时
public const uint Error_NotFindEntity = 100000008; // 没有找到Entity
}
}

View File

@@ -399,12 +399,6 @@ namespace TEngine
public void Deserialize(Scene scene, bool resetId = false)
{
if (IsDisposed)
{
Log.Error($"component is Disposed {this.GetType().FullName}");
return;
}
if (RuntimeId != 0)
{
return;

View File

@@ -70,7 +70,7 @@ namespace TEngine
public void CreateSession(string remoteAddress, NetworkProtocolType networkProtocolType, Action onConnectComplete, Action onConnectFail, int connectTimeout = 5000)
{
var address = NetworkHelper.ToIPEndPoint(remoteAddress);
var clientNetworkComponent = AddComponent<ClientNetworkComponent>();
var clientNetworkComponent = GetComponent<ClientNetworkComponent>() ?? AddComponent<ClientNetworkComponent>();
clientNetworkComponent.Initialize(networkProtocolType, NetworkTarget.Outer);
clientNetworkComponent.Connect(address, onConnectComplete, onConnectFail, connectTimeout);
Session = clientNetworkComponent.Session;

View File

@@ -246,7 +246,7 @@ public sealed class ProtoBufExporter
{
opcodeInfo.Code += ++_aResponse;
file.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]");
file.AppendLine("\t\tpublic int ErrorCode { get; set; }");
file.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
break;
}
default:
@@ -263,7 +263,7 @@ public sealed class ProtoBufExporter
{
opcodeInfo.Code += ++_aRouteResponse;
file.AppendLine("\t\t[ProtoMember(91, IsRequired = true)]");
file.AppendLine("\t\tpublic int ErrorCode { get; set; }");
file.AppendLine("\t\tpublic uint ErrorCode { get; set; }");
}
break;

View File

@@ -112,7 +112,7 @@ namespace TEngine.Core.Network
if (networkId != 0 && channelId != 0)
{
NetworkThread.Instance.SynchronizationContext.Post(() =>
NetworkThread.Instance?.SynchronizationContext.Post(() =>
{
NetworkThread.Instance?.RemoveChannel(networkId, channelId);
});

View File

@@ -212,7 +212,7 @@ namespace TEngine.Core.Network
}
}
#endif
public void FailResponse(Session session, IRouteRequest iRouteRequest, int error, uint rpcId)
public void FailResponse(Session session, IRouteRequest iRouteRequest, uint error, uint rpcId)
{
var response = CreateResponse(iRouteRequest, error);
session.Send(response, rpcId);
@@ -223,7 +223,7 @@ namespace TEngine.Core.Network
return new RouteResponse();
}
public IResponse CreateResponse(Type requestType, int error)
public IResponse CreateResponse(Type requestType, uint error)
{
IResponse response;
@@ -240,7 +240,7 @@ namespace TEngine.Core.Network
return response;
}
public IResponse CreateResponse(IRequest iRequest, int error)
public IResponse CreateResponse(IRequest iRequest, uint error)
{
IResponse response;
@@ -257,7 +257,7 @@ namespace TEngine.Core.Network
return response;
}
public IRouteResponse CreateResponse(IRouteRequest iRouteRequest, int error)
public IRouteResponse CreateResponse(IRouteRequest iRouteRequest, uint error)
{
IRouteResponse response;

View File

@@ -12,6 +12,6 @@ namespace TEngine.Core.Network
public interface IResponse : IMessage
{
int ErrorCode { get; set; }
uint ErrorCode { get; set; }
}
}

View File

@@ -12,7 +12,7 @@ namespace TEngine
}
[ProtoMember(90)] public long RpcId { get; set; }
[ProtoMember(91, IsRequired = true)] public int ErrorCode { get; set; }
[ProtoMember(91, IsRequired = true)] public uint ErrorCode { get; set; }
}
[ProtoContract]
@@ -24,7 +24,7 @@ namespace TEngine
}
[ProtoMember(90)] public long RpcId { get; set; }
[ProtoMember(91, IsRequired = true)] public int ErrorCode { get; set; }
[ProtoMember(91, IsRequired = true)] public uint ErrorCode { get; set; }
}
[ProtoContract]
public class PingRequest : AProto, IRequest
@@ -46,7 +46,7 @@ namespace TEngine
}
[ProtoMember(90)] public long RpcId { get; set; }
[ProtoMember(91, IsRequired = true)] public int ErrorCode { get; set; }
[ProtoMember(91, IsRequired = true)] public uint ErrorCode { get; set; }
[ProtoMember(1)] public long Now;
}
/// <summary>
@@ -69,7 +69,7 @@ namespace TEngine
{
public uint OpCode() { return Opcode.AddressableAddResponse; }
[ProtoMember(91, IsRequired = true)]
public int ErrorCode { get; set; }
public uint ErrorCode { get; set; }
}
/// <summary>
/// 查询一个可寻址
@@ -89,7 +89,7 @@ namespace TEngine
{
public uint OpCode() { return Opcode.AddressableGetResponse; }
[ProtoMember(91, IsRequired = true)]
public int ErrorCode { get; set; }
public uint ErrorCode { get; set; }
[ProtoMember(1)]
public long RouteId { get; set; }
}
@@ -111,7 +111,7 @@ namespace TEngine
{
public uint OpCode() { return Opcode.AddressableRemoveResponse; }
[ProtoMember(91, IsRequired = true)]
public int ErrorCode { get; set; }
public uint ErrorCode { get; set; }
}
/// <summary>
/// 锁定一个可寻址
@@ -131,7 +131,7 @@ namespace TEngine
{
public uint OpCode() { return Opcode.AddressableLockResponse; }
[ProtoMember(91, IsRequired = true)]
public int ErrorCode { get; set; }
public uint ErrorCode { get; set; }
}
/// <summary>
/// 解锁一个可寻址
@@ -155,6 +155,6 @@ namespace TEngine
{
public uint OpCode() { return Opcode.AddressableUnLockResponse; }
[ProtoMember(91, IsRequired = true)]
public int ErrorCode { get; set; }
public uint ErrorCode { get; set; }
}
}