diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs index 76d5c4b62..3be640f01 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs @@ -1,606 +1,485 @@ using ProtoBuf; + using System.Collections.Generic; using NBC; using NBC.Network.Interface; using NBC.Serialize; - #pragma warning disable CS8618 namespace NBC { - [ProtoContract] - public partial class C2A_RegisterRequest : AMessage, IRequest, IProto - { - public static C2A_RegisterRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - Username = default; - Password = default; + [ProtoContract] + public partial class C2A_RegisterRequest : AMessage, IRequest, IProto + { + public static C2A_RegisterRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Username = default; + Password = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public A2C_RegisterResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2A_RegisterRequest; - } - - [ProtoMember(1)] public string Username { get; set; } - [ProtoMember(2)] public string Password { get; set; } - } - - [ProtoContract] - public partial class A2C_RegisterResponse : AMessage, IResponse, IProto - { - public static A2C_RegisterResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; + } + [ProtoIgnore] + public A2C_RegisterResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2A_RegisterRequest; } + [ProtoMember(1)] + public string Username { get; set; } + [ProtoMember(2)] + public string Password { get; set; } + } + [ProtoContract] + public partial class A2C_RegisterResponse : AMessage, IResponse, IProto + { + public static A2C_RegisterResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.A2C_RegisterResponse; - } - - [ProtoMember(1)] public uint ErrorCode { get; set; } - } - - [ProtoContract] - public partial class C2A_LoginRequest : AMessage, IRequest, IProto - { - public static C2A_LoginRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - Username = default; - Password = default; - LoginType = default; + } + public uint OpCode() { return OuterOpcode.A2C_RegisterResponse; } + [ProtoMember(1)] + public uint ErrorCode { get; set; } + } + [ProtoContract] + public partial class C2A_LoginRequest : AMessage, IRequest, IProto + { + public static C2A_LoginRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Username = default; + Password = default; + LoginType = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public A2C_LoginResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2A_LoginRequest; - } - - [ProtoMember(1)] public string Username { get; set; } - [ProtoMember(2)] public string Password { get; set; } - [ProtoMember(3)] public int LoginType { get; set; } - } - - [ProtoContract] - public partial class A2C_LoginResponse : AMessage, IResponse, IProto - { - public static A2C_LoginResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; - ToKen = default; + } + [ProtoIgnore] + public A2C_LoginResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2A_LoginRequest; } + [ProtoMember(1)] + public string Username { get; set; } + [ProtoMember(2)] + public string Password { get; set; } + [ProtoMember(3)] + public int LoginType { get; set; } + } + [ProtoContract] + public partial class A2C_LoginResponse : AMessage, IResponse, IProto + { + public static A2C_LoginResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + ToKen = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.A2C_LoginResponse; - } - - [ProtoMember(1)] public string ToKen { get; set; } - [ProtoMember(2)] public uint ErrorCode { get; set; } - } - - /// - /// 客户端登录到Gate服务器 - /// - [ProtoContract] - public partial class C2G_LoginRequest : AMessage, IRequest, IProto - { - public static C2G_LoginRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ToKen = default; + } + public uint OpCode() { return OuterOpcode.A2C_LoginResponse; } + [ProtoMember(1)] + public string ToKen { get; set; } + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } + /// + /// 客户端登录到Gate服务器 + /// + [ProtoContract] + public partial class C2G_LoginRequest : AMessage, IRequest, IProto + { + public static C2G_LoginRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ToKen = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public G2C_LoginResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2G_LoginRequest; - } - - [ProtoMember(1)] public string ToKen { get; set; } - } - - [ProtoContract] - public partial class G2C_LoginResponse : AMessage, IResponse, IProto - { - public static G2C_LoginResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; - GameAccountInfo = default; + } + [ProtoIgnore] + public G2C_LoginResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2G_LoginRequest; } + [ProtoMember(1)] + public string ToKen { get; set; } + } + [ProtoContract] + public partial class G2C_LoginResponse : AMessage, IResponse, IProto + { + public static G2C_LoginResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + GameAccountInfo = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.G2C_LoginResponse; - } - - [ProtoMember(1)] public GameAccountInfo GameAccountInfo { get; set; } - [ProtoMember(2)] public uint ErrorCode { get; set; } - } - - /// - /// 通知客户端重复登录 - /// - [ProtoContract] - public partial class G2C_RepeatLogin : AMessage, IMessage, IProto - { - public static G2C_RepeatLogin Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { + } + public uint OpCode() { return OuterOpcode.G2C_LoginResponse; } + [ProtoMember(1)] + public GameAccountInfo GameAccountInfo { get; set; } + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } + /// + /// 通知客户端重复登录 + /// + [ProtoContract] + public partial class G2C_RepeatLogin : AMessage, IMessage, IProto + { + public static G2C_RepeatLogin Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.G2C_RepeatLogin; - } - } - - /// - /// GameAccount实体类 - /// - [ProtoContract] - public partial class GameAccountInfo : AMessage, IProto - { - public static GameAccountInfo Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - CreateTime = default; - LoginTime = default; + } + public uint OpCode() { return OuterOpcode.G2C_RepeatLogin; } + } + /// + /// GameAccount实体类 + /// + [ProtoContract] + public partial class GameAccountInfo : AMessage, IProto + { + public static GameAccountInfo Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + CreateTime = default; + LoginTime = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoMember(1)] public long CreateTime { get; set; } - [ProtoMember(2)] public long LoginTime { get; set; } - } - - /// - /// 拿到当前账号的信息 - /// - [ProtoContract] - public partial class C2G_GetAccountInfoRequest : AMessage, IRequest, IProto - { - public static C2G_GetAccountInfoRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { + } + [ProtoMember(1)] + public long CreateTime { get; set; } + [ProtoMember(2)] + public long LoginTime { get; set; } + } + /// + /// 拿到当前账号的信息 + /// + [ProtoContract] + public partial class C2G_GetAccountInfoRequest : AMessage, IRequest, IProto + { + public static C2G_GetAccountInfoRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public G2C_GetAccountInfoResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2G_GetAccountInfoRequest; - } - } - - [ProtoContract] - public partial class G2C_GetAccountInfoResponse : AMessage, IResponse, IProto - { - public static G2C_GetAccountInfoResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; - GameAccountInfo = default; + } + [ProtoIgnore] + public G2C_GetAccountInfoResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2G_GetAccountInfoRequest; } + } + [ProtoContract] + public partial class G2C_GetAccountInfoResponse : AMessage, IResponse, IProto + { + public static G2C_GetAccountInfoResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + GameAccountInfo = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.G2C_GetAccountInfoResponse; - } - - [ProtoMember(1)] public GameAccountInfo GameAccountInfo { get; set; } - [ProtoMember(2)] public uint ErrorCode { get; set; } - } - - [ProtoContract] - public partial class C2G_TestMessage : AMessage, IMessage, IProto - { - public static C2G_TestMessage Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - Tag = default; + } + public uint OpCode() { return OuterOpcode.G2C_GetAccountInfoResponse; } + [ProtoMember(1)] + public GameAccountInfo GameAccountInfo { get; set; } + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } + [ProtoContract] + public partial class C2G_TestMessage : AMessage, IMessage, IProto + { + public static C2G_TestMessage Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.C2G_TestMessage; - } - - [ProtoMember(1)] public string Tag { get; set; } - } - - [ProtoContract] - public partial class C2G_TestRequest : AMessage, IRequest, IProto - { - public static C2G_TestRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - Tag = default; + } + public uint OpCode() { return OuterOpcode.C2G_TestMessage; } + [ProtoMember(1)] + public string Tag { get; set; } + } + [ProtoContract] + public partial class C2G_TestRequest : AMessage, IRequest, IProto + { + public static C2G_TestRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public G2C_TestResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2G_TestRequest; - } - - [ProtoMember(1)] public string Tag { get; set; } - } - - [ProtoContract] - public partial class G2C_TestResponse : AMessage, IResponse, IProto - { - public static G2C_TestResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; - Tag = default; + } + [ProtoIgnore] + public G2C_TestResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2G_TestRequest; } + [ProtoMember(1)] + public string Tag { get; set; } + } + [ProtoContract] + public partial class G2C_TestResponse : AMessage, IResponse, IProto + { + public static G2C_TestResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.G2C_TestResponse; - } - - [ProtoMember(1)] public string Tag { get; set; } - [ProtoMember(2)] public uint ErrorCode { get; set; } - } - - [ProtoContract] - public partial class C2G_CreateAddressableRequest : AMessage, IRequest, IProto - { - public static C2G_CreateAddressableRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { + } + public uint OpCode() { return OuterOpcode.G2C_TestResponse; } + [ProtoMember(1)] + public string Tag { get; set; } + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } + [ProtoContract] + public partial class C2G_CreateAddressableRequest : AMessage, IRequest, IProto + { + public static C2G_CreateAddressableRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public G2C_CreateAddressableResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2G_CreateAddressableRequest; - } - } - - [ProtoContract] - public partial class G2C_CreateAddressableResponse : AMessage, IResponse, IProto - { - public static G2C_CreateAddressableResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; + } + [ProtoIgnore] + public G2C_CreateAddressableResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2G_CreateAddressableRequest; } + } + [ProtoContract] + public partial class G2C_CreateAddressableResponse : AMessage, IResponse, IProto + { + public static G2C_CreateAddressableResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.G2C_CreateAddressableResponse; - } - - [ProtoMember(1)] public uint ErrorCode { get; set; } - } - - [ProtoContract] - public partial class C2M_TestMessage : AMessage, IAddressableRouteMessage, IProto - { - public static C2M_TestMessage Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - Tag = default; + } + public uint OpCode() { return OuterOpcode.G2C_CreateAddressableResponse; } + [ProtoMember(1)] + public uint ErrorCode { get; set; } + } + [ProtoContract] + public partial class C2M_TestMessage : AMessage, IAddressableRouteMessage, IProto + { + public static C2M_TestMessage Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.C2M_TestMessage; - } - - [ProtoMember(1)] public string Tag { get; set; } - } - - [ProtoContract] - public partial class C2M_TestRequest : AMessage, IAddressableRouteRequest, IProto - { - public static C2M_TestRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - Tag = default; + } + public uint OpCode() { return OuterOpcode.C2M_TestMessage; } + [ProtoMember(1)] + public string Tag { get; set; } + } + [ProtoContract] + public partial class C2M_TestRequest : AMessage, IAddressableRouteRequest, IProto + { + public static C2M_TestRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public M2C_TestResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2M_TestRequest; - } - - [ProtoMember(1)] public string Tag { get; set; } - } - - [ProtoContract] - public partial class M2C_TestResponse : AMessage, IAddressableRouteResponse, IProto - { - public static M2C_TestResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; - Tag = default; + } + [ProtoIgnore] + public M2C_TestResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2M_TestRequest; } + [ProtoMember(1)] + public string Tag { get; set; } + } + [ProtoContract] + public partial class M2C_TestResponse : AMessage, IAddressableRouteResponse, IProto + { + public static M2C_TestResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.M2C_TestResponse; - } - - [ProtoMember(1)] public string Tag { get; set; } - [ProtoMember(2)] public uint ErrorCode { get; set; } - } - - /// - /// 通知Gate服务器创建一个Chat的Route连接 - /// - [ProtoContract] - public partial class C2G_CreateChatRouteRequest : AMessage, IRequest, IProto - { - public static C2G_CreateChatRouteRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { + } + public uint OpCode() { return OuterOpcode.M2C_TestResponse; } + [ProtoMember(1)] + public string Tag { get; set; } + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } + /// + /// 通知Gate服务器创建一个Chat的Route连接 + /// + [ProtoContract] + public partial class C2G_CreateChatRouteRequest : AMessage, IRequest, IProto + { + public static C2G_CreateChatRouteRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public G2C_CreateChatRouteResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2G_CreateChatRouteRequest; - } - } - - [ProtoContract] - public partial class G2C_CreateChatRouteResponse : AMessage, IResponse, IProto - { - public static G2C_CreateChatRouteResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; + } + [ProtoIgnore] + public G2C_CreateChatRouteResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2G_CreateChatRouteRequest; } + } + [ProtoContract] + public partial class G2C_CreateChatRouteResponse : AMessage, IResponse, IProto + { + public static G2C_CreateChatRouteResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.G2C_CreateChatRouteResponse; - } - - [ProtoMember(1)] public uint ErrorCode { get; set; } - } - - /// - /// 发送一个Route消息给Chat - /// - [ProtoContract] - public partial class C2Chat_TestMessage : AMessage, ICustomRouteMessage, IProto - { - public static C2Chat_TestMessage Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - Tag = default; + } + public uint OpCode() { return OuterOpcode.G2C_CreateChatRouteResponse; } + [ProtoMember(1)] + public uint ErrorCode { get; set; } + } + /// + /// 发送一个Route消息给Chat + /// + [ProtoContract] + public partial class C2Chat_TestMessage : AMessage, ICustomRouteMessage, IProto + { + public static C2Chat_TestMessage Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.C2Chat_TestMessage; - } - - [ProtoIgnore] public int RouteType => NBC.RouteType.ChatRoute; - [ProtoMember(1)] public string Tag { get; set; } - } - - /// - /// 发送一个RPCRoute消息给Chat - /// - [ProtoContract] - public partial class C2Chat_TestMessageRequest : AMessage, ICustomRouteRequest, IProto - { - public static C2Chat_TestMessageRequest Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - Tag = default; + } + public uint OpCode() { return OuterOpcode.C2Chat_TestMessage; } + [ProtoIgnore] + public int RouteType => NBC.RouteType.ChatRoute; + [ProtoMember(1)] + public string Tag { get; set; } + } + /// + /// 发送一个RPCRoute消息给Chat + /// + [ProtoContract] + public partial class C2Chat_TestMessageRequest : AMessage, ICustomRouteRequest, IProto + { + public static C2Chat_TestMessageRequest Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - [ProtoIgnore] public Chat2C_TestMessageResponse ResponseType { get; set; } - - public uint OpCode() - { - return OuterOpcode.C2Chat_TestMessageRequest; - } - - [ProtoIgnore] public int RouteType => NBC.RouteType.ChatRoute; - [ProtoMember(1)] public string Tag { get; set; } - } - - [ProtoContract] - public partial class Chat2C_TestMessageResponse : AMessage, ICustomRouteResponse, IProto - { - public static Chat2C_TestMessageResponse Create(Scene scene) - { - return scene.MessagePoolComponent.Rent(); - } - - public override void Dispose() - { - ErrorCode = default; - Tag = default; + } + [ProtoIgnore] + public Chat2C_TestMessageResponse ResponseType { get; set; } + public uint OpCode() { return OuterOpcode.C2Chat_TestMessageRequest; } + [ProtoIgnore] + public int RouteType => NBC.RouteType.ChatRoute; + [ProtoMember(1)] + public string Tag { get; set; } + } + [ProtoContract] + public partial class Chat2C_TestMessageResponse : AMessage, ICustomRouteResponse, IProto + { + public static Chat2C_TestMessageResponse Create(Scene scene) + { + return scene.MessagePoolComponent.Rent(); + } + public override void Dispose() + { + ErrorCode = default; + Tag = default; #if FANTASY_NET || FANTASY_UNITY GetScene().MessagePoolComponent.Return(this); #endif - } - - public uint OpCode() - { - return OuterOpcode.Chat2C_TestMessageResponse; - } - - [ProtoMember(1)] public string Tag { get; set; } - [ProtoMember(2)] public uint ErrorCode { get; set; } - } -} \ No newline at end of file + } + public uint OpCode() { return OuterOpcode.Chat2C_TestMessageResponse; } + [ProtoMember(1)] + public string Tag { get; set; } + [ProtoMember(2)] + public uint ErrorCode { get; set; } + } +} diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs.meta b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs.meta index 8002bf12f..388557618 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs.meta +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs.meta @@ -1,2 +1,11 @@ fileFormatVersion: 2 -guid: cf5bc579defd25640b8f277220459410 \ No newline at end of file +guid: ac16629ba2ddb4832bfc3548b7a92da0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs.meta b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs.meta index 42fa8a791..99316514a 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs.meta +++ b/Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs.meta @@ -1,2 +1,11 @@ fileFormatVersion: 2 -guid: dc84d27ae0bdf764fb50b6d543cbcf7e \ No newline at end of file +guid: 79e8bd7cb8ff94462a0108fac5149a46 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs b/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs index a885e2d26..b37ab47f2 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs +++ b/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs @@ -1,9 +1,9 @@ namespace NBC { - // Route协议定义(需要定义1000以上、因为1000以内的框架预留) - public static class RouteType - { - public const int GateRoute = 1001; // Gate - public const int ChatRoute = 1002; // Chat - } -} \ No newline at end of file + // Route协议定义(需要定义1000以上、因为1000以内的框架预留) + public static class RouteType + { + public const int GateRoute = 1001; // Gate + public const int ChatRoute = 1002; // Chat + } +} diff --git a/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs.meta b/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs.meta index fd249cfe8..205aa1d65 100644 --- a/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs.meta +++ b/Assets/Scripts/Generate/NetworkProtocol/RouteType.cs.meta @@ -1,2 +1,11 @@ fileFormatVersion: 2 -guid: 76b668cc0db30b34ab2a64d695b14ac4 \ No newline at end of file +guid: 93ff0f8f28d294cdab3c6346d873065d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/NBC/Runtime/Core/App.cs b/Assets/Scripts/NBC/Runtime/Core/App.cs index 4b314f6e1..d1e3b755f 100644 --- a/Assets/Scripts/NBC/Runtime/Core/App.cs +++ b/Assets/Scripts/NBC/Runtime/Core/App.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using UnityEngine; namespace NBC @@ -73,10 +74,34 @@ namespace NBC private async FTask StartAsync() { // 初始化框架 - await NBC.Platform.Unity.Entry.Initialize(GetType().Assembly); + var assemblies = AppDomain.CurrentDomain.GetAssemblies(); + List loadAssemblies = new List(); + foreach (var assembly in assemblies) + { + // 跳过系统程序集以提高性能(可选) + if (IsSystemAssembly(assembly)) + continue; + loadAssemblies.Add(assembly); + } + + await NBC.Platform.Unity.Entry.Initialize(loadAssemblies.ToArray()); _scene = await Scene.Create(SceneRuntimeMode.MainThread); UI = _scene.AddComponent(); OnInitialized?.Invoke(); } + + // 判断是否是系统程序集(可选优化) + private static bool IsSystemAssembly(System.Reflection.Assembly assembly) + { + string assemblyName = assembly.FullName; + return assemblyName.StartsWith("System") || + assemblyName.StartsWith("Microsoft.") || + assemblyName.StartsWith("UnityEngine") || + assemblyName.StartsWith("UnityEditor") || + assemblyName.StartsWith("mscorlib") || + assemblyName.StartsWith("netstandard") || + assemblyName.StartsWith("nunit.") || + assemblyName.StartsWith("Unity."); + } } } \ No newline at end of file diff --git a/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/MessageDispatcherComponent.cs b/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/MessageDispatcherComponent.cs index 826b1d848..421cb5545 100644 --- a/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/MessageDispatcherComponent.cs +++ b/Assets/Scripts/NBC/Runtime/Core/Network/Message/Dispatcher/MessageDispatcherComponent.cs @@ -72,8 +72,9 @@ namespace NBC.Network.Interface private void LoadInner(long assemblyIdentity) { + var nmsl = AssemblySystem.ForEach(assemblyIdentity, typeof(IMessage)); // 遍历所有实现了IMessage接口的类型,获取OpCode并添加到_networkProtocols字典中 - foreach (var type in AssemblySystem.ForEach(assemblyIdentity, typeof(IMessage))) + foreach (var type in nmsl) { var obj = (IMessage) Activator.CreateInstance(type); var opCode = obj.OpCode(); diff --git a/Assets/Scripts/NBC/Runtime/Core/Network/Message/PacketParser/Handler/BufferPacketParser.cs b/Assets/Scripts/NBC/Runtime/Core/Network/Message/PacketParser/Handler/BufferPacketParser.cs index e34652f0f..7ff8e8b8f 100644 --- a/Assets/Scripts/NBC/Runtime/Core/Network/Message/PacketParser/Handler/BufferPacketParser.cs +++ b/Assets/Scripts/NBC/Runtime/Core/Network/Message/PacketParser/Handler/BufferPacketParser.cs @@ -231,6 +231,7 @@ namespace NBC.PacketParser var memoryStreamLength = 0; var messageType = message.GetType(); var memoryStream = Network.MemoryStreamBufferPool.RentMemoryStream(MemoryStreamBufferSource.Pack); + var nmsl = message.OpCode(); OpCodeIdStruct opCodeIdStruct = message.OpCode(); memoryStream.Seek(Packet.OuterPacketHeadLength, SeekOrigin.Begin); diff --git a/Assets/Scripts/Startup/Init.cs b/Assets/Scripts/Startup/Init.cs index 27000b8d2..6a7d57101 100644 --- a/Assets/Scripts/Startup/Init.cs +++ b/Assets/Scripts/Startup/Init.cs @@ -5,6 +5,7 @@ using Assets.Scripts.Hotfix; using FairyGUI; using NBC; using NBC.Network; +using NBC.Platform.Unity; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Video; @@ -150,18 +151,31 @@ namespace NBF private async FTask OnLoginButtonClick() { + // NBC.Platform.Unity.Entry.Initialize(GetType().Assembly); + // 根据用户名来选择目标的鉴权服务器 // 根据鉴权服务器地址来创建一个新的网络会话 _session = SessionHelper.CreateSession(App.Main, "127.0.0.1:20001", OnConnectComplete, OnConnectFail, OnConnectDisconnect); + + var acc = "test001"; + + // // 发送一个注册的请求消息到目标服务器 + // var responseReg = (A2C_RegisterResponse)await _session.Call(new C2A_RegisterRequest() + // { + // Username = acc, + // Password = acc + // }); + // 发送登录的请求给服务器 var response = (A2C_LoginResponse)await _session.Call(new C2A_LoginRequest() { - Username = "test001", - Password = "test001", + Username = acc, + Password = acc, LoginType = 1 }); + if (response.ErrorCode != 0) { Log.Error($"登录发生错误{response.ErrorCode}"); diff --git a/Fishing2.sln.DotSettings.user b/Fishing2.sln.DotSettings.user index bae2e9e8a..6eeb723e7 100644 --- a/Fishing2.sln.DotSettings.user +++ b/Fishing2.sln.DotSettings.user @@ -12,6 +12,7 @@ ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded ForceIncluded