介入网络收发

This commit is contained in:
bob
2025-07-26 15:19:14 +08:00
parent 88cea0b5c6
commit 553153c61d
10 changed files with 490 additions and 542 deletions

View File

@@ -1,9 +1,9 @@
using ProtoBuf; using ProtoBuf;
using System.Collections.Generic; using System.Collections.Generic;
using NBC; using NBC;
using NBC.Network.Interface; using NBC.Network.Interface;
using NBC.Serialize; using NBC.Serialize;
#pragma warning disable CS8618 #pragma warning disable CS8618
namespace NBC namespace NBC
@@ -15,7 +15,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2A_RegisterRequest>(); return scene.MessagePoolComponent.Rent<C2A_RegisterRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
Username = default; Username = default;
@@ -24,18 +23,14 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2A_RegisterRequest>(this); GetScene().MessagePoolComponent.Return<C2A_RegisterRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public A2C_RegisterResponse ResponseType { get; set; } public A2C_RegisterResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2A_RegisterRequest; }
public uint OpCode() [ProtoMember(1)]
{ public string Username { get; set; }
return OuterOpcode.C2A_RegisterRequest; [ProtoMember(2)]
public string Password { get; set; }
} }
[ProtoMember(1)] public string Username { get; set; }
[ProtoMember(2)] public string Password { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class A2C_RegisterResponse : AMessage, IResponse, IProto public partial class A2C_RegisterResponse : AMessage, IResponse, IProto
{ {
@@ -43,7 +38,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<A2C_RegisterResponse>(); return scene.MessagePoolComponent.Rent<A2C_RegisterResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -51,15 +45,10 @@ namespace NBC
GetScene().MessagePoolComponent.Return<A2C_RegisterResponse>(this); GetScene().MessagePoolComponent.Return<A2C_RegisterResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.A2C_RegisterResponse; }
public uint OpCode() [ProtoMember(1)]
{ public uint ErrorCode { get; set; }
return OuterOpcode.A2C_RegisterResponse;
} }
[ProtoMember(1)] public uint ErrorCode { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class C2A_LoginRequest : AMessage, IRequest, IProto public partial class C2A_LoginRequest : AMessage, IRequest, IProto
{ {
@@ -67,7 +56,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2A_LoginRequest>(); return scene.MessagePoolComponent.Rent<C2A_LoginRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
Username = default; Username = default;
@@ -77,19 +65,16 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2A_LoginRequest>(this); GetScene().MessagePoolComponent.Return<C2A_LoginRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public A2C_LoginResponse ResponseType { get; set; } public A2C_LoginResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2A_LoginRequest; }
public uint OpCode() [ProtoMember(1)]
{ public string Username { get; set; }
return OuterOpcode.C2A_LoginRequest; [ProtoMember(2)]
public string Password { get; set; }
[ProtoMember(3)]
public int LoginType { get; set; }
} }
[ProtoMember(1)] public string Username { get; set; }
[ProtoMember(2)] public string Password { get; set; }
[ProtoMember(3)] public int LoginType { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class A2C_LoginResponse : AMessage, IResponse, IProto public partial class A2C_LoginResponse : AMessage, IResponse, IProto
{ {
@@ -97,7 +82,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<A2C_LoginResponse>(); return scene.MessagePoolComponent.Rent<A2C_LoginResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -106,16 +90,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<A2C_LoginResponse>(this); GetScene().MessagePoolComponent.Return<A2C_LoginResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.A2C_LoginResponse; }
public uint OpCode() [ProtoMember(1)]
{ public string ToKen { get; set; }
return OuterOpcode.A2C_LoginResponse; [ProtoMember(2)]
public uint ErrorCode { get; set; }
} }
[ProtoMember(1)] public string ToKen { get; set; }
[ProtoMember(2)] public uint ErrorCode { get; set; }
}
/// <summary> /// <summary>
/// 客户端登录到Gate服务器 /// 客户端登录到Gate服务器
/// </summary> /// </summary>
@@ -126,7 +106,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2G_LoginRequest>(); return scene.MessagePoolComponent.Rent<C2G_LoginRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
ToKen = default; ToKen = default;
@@ -134,17 +113,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2G_LoginRequest>(this); GetScene().MessagePoolComponent.Return<C2G_LoginRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public G2C_LoginResponse ResponseType { get; set; } public G2C_LoginResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2G_LoginRequest; }
public uint OpCode() [ProtoMember(1)]
{ public string ToKen { get; set; }
return OuterOpcode.C2G_LoginRequest;
} }
[ProtoMember(1)] public string ToKen { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class G2C_LoginResponse : AMessage, IResponse, IProto public partial class G2C_LoginResponse : AMessage, IResponse, IProto
{ {
@@ -152,7 +126,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<G2C_LoginResponse>(); return scene.MessagePoolComponent.Rent<G2C_LoginResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -161,16 +134,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<G2C_LoginResponse>(this); GetScene().MessagePoolComponent.Return<G2C_LoginResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.G2C_LoginResponse; }
public uint OpCode() [ProtoMember(1)]
{ public GameAccountInfo GameAccountInfo { get; set; }
return OuterOpcode.G2C_LoginResponse; [ProtoMember(2)]
public uint ErrorCode { get; set; }
} }
[ProtoMember(1)] public GameAccountInfo GameAccountInfo { get; set; }
[ProtoMember(2)] public uint ErrorCode { get; set; }
}
/// <summary> /// <summary>
/// 通知客户端重复登录 /// 通知客户端重复登录
/// </summary> /// </summary>
@@ -181,20 +150,14 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<G2C_RepeatLogin>(); return scene.MessagePoolComponent.Rent<G2C_RepeatLogin>();
} }
public override void Dispose() public override void Dispose()
{ {
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<G2C_RepeatLogin>(this); GetScene().MessagePoolComponent.Return<G2C_RepeatLogin>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.G2C_RepeatLogin; }
public uint OpCode()
{
return OuterOpcode.G2C_RepeatLogin;
} }
}
/// <summary> /// <summary>
/// GameAccount实体类 /// GameAccount实体类
/// </summary> /// </summary>
@@ -205,7 +168,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<GameAccountInfo>(); return scene.MessagePoolComponent.Rent<GameAccountInfo>();
} }
public override void Dispose() public override void Dispose()
{ {
CreateTime = default; CreateTime = default;
@@ -214,11 +176,11 @@ namespace NBC
GetScene().MessagePoolComponent.Return<GameAccountInfo>(this); GetScene().MessagePoolComponent.Return<GameAccountInfo>(this);
#endif #endif
} }
[ProtoMember(1)]
[ProtoMember(1)] public long CreateTime { get; set; } public long CreateTime { get; set; }
[ProtoMember(2)] public long LoginTime { get; set; } [ProtoMember(2)]
public long LoginTime { get; set; }
} }
/// <summary> /// <summary>
/// 拿到当前账号的信息 /// 拿到当前账号的信息
/// </summary> /// </summary>
@@ -229,22 +191,16 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2G_GetAccountInfoRequest>(); return scene.MessagePoolComponent.Rent<C2G_GetAccountInfoRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2G_GetAccountInfoRequest>(this); GetScene().MessagePoolComponent.Return<C2G_GetAccountInfoRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public G2C_GetAccountInfoResponse ResponseType { get; set; } public G2C_GetAccountInfoResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2G_GetAccountInfoRequest; }
public uint OpCode()
{
return OuterOpcode.C2G_GetAccountInfoRequest;
} }
}
[ProtoContract] [ProtoContract]
public partial class G2C_GetAccountInfoResponse : AMessage, IResponse, IProto public partial class G2C_GetAccountInfoResponse : AMessage, IResponse, IProto
{ {
@@ -252,7 +208,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<G2C_GetAccountInfoResponse>(); return scene.MessagePoolComponent.Rent<G2C_GetAccountInfoResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -261,16 +216,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<G2C_GetAccountInfoResponse>(this); GetScene().MessagePoolComponent.Return<G2C_GetAccountInfoResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.G2C_GetAccountInfoResponse; }
public uint OpCode() [ProtoMember(1)]
{ public GameAccountInfo GameAccountInfo { get; set; }
return OuterOpcode.G2C_GetAccountInfoResponse; [ProtoMember(2)]
public uint ErrorCode { get; set; }
} }
[ProtoMember(1)] public GameAccountInfo GameAccountInfo { get; set; }
[ProtoMember(2)] public uint ErrorCode { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class C2G_TestMessage : AMessage, IMessage, IProto public partial class C2G_TestMessage : AMessage, IMessage, IProto
{ {
@@ -278,7 +229,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2G_TestMessage>(); return scene.MessagePoolComponent.Rent<C2G_TestMessage>();
} }
public override void Dispose() public override void Dispose()
{ {
Tag = default; Tag = default;
@@ -286,15 +236,10 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2G_TestMessage>(this); GetScene().MessagePoolComponent.Return<C2G_TestMessage>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.C2G_TestMessage; }
public uint OpCode() [ProtoMember(1)]
{ public string Tag { get; set; }
return OuterOpcode.C2G_TestMessage;
} }
[ProtoMember(1)] public string Tag { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class C2G_TestRequest : AMessage, IRequest, IProto public partial class C2G_TestRequest : AMessage, IRequest, IProto
{ {
@@ -302,7 +247,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2G_TestRequest>(); return scene.MessagePoolComponent.Rent<C2G_TestRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
Tag = default; Tag = default;
@@ -310,17 +254,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2G_TestRequest>(this); GetScene().MessagePoolComponent.Return<C2G_TestRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public G2C_TestResponse ResponseType { get; set; } public G2C_TestResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2G_TestRequest; }
public uint OpCode() [ProtoMember(1)]
{ public string Tag { get; set; }
return OuterOpcode.C2G_TestRequest;
} }
[ProtoMember(1)] public string Tag { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class G2C_TestResponse : AMessage, IResponse, IProto public partial class G2C_TestResponse : AMessage, IResponse, IProto
{ {
@@ -328,7 +267,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<G2C_TestResponse>(); return scene.MessagePoolComponent.Rent<G2C_TestResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -337,16 +275,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<G2C_TestResponse>(this); GetScene().MessagePoolComponent.Return<G2C_TestResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.G2C_TestResponse; }
public uint OpCode() [ProtoMember(1)]
{ public string Tag { get; set; }
return OuterOpcode.G2C_TestResponse; [ProtoMember(2)]
public uint ErrorCode { get; set; }
} }
[ProtoMember(1)] public string Tag { get; set; }
[ProtoMember(2)] public uint ErrorCode { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class C2G_CreateAddressableRequest : AMessage, IRequest, IProto public partial class C2G_CreateAddressableRequest : AMessage, IRequest, IProto
{ {
@@ -354,22 +288,16 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2G_CreateAddressableRequest>(); return scene.MessagePoolComponent.Rent<C2G_CreateAddressableRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2G_CreateAddressableRequest>(this); GetScene().MessagePoolComponent.Return<C2G_CreateAddressableRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public G2C_CreateAddressableResponse ResponseType { get; set; } public G2C_CreateAddressableResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2G_CreateAddressableRequest; }
public uint OpCode()
{
return OuterOpcode.C2G_CreateAddressableRequest;
} }
}
[ProtoContract] [ProtoContract]
public partial class G2C_CreateAddressableResponse : AMessage, IResponse, IProto public partial class G2C_CreateAddressableResponse : AMessage, IResponse, IProto
{ {
@@ -377,7 +305,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<G2C_CreateAddressableResponse>(); return scene.MessagePoolComponent.Rent<G2C_CreateAddressableResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -385,15 +312,10 @@ namespace NBC
GetScene().MessagePoolComponent.Return<G2C_CreateAddressableResponse>(this); GetScene().MessagePoolComponent.Return<G2C_CreateAddressableResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.G2C_CreateAddressableResponse; }
public uint OpCode() [ProtoMember(1)]
{ public uint ErrorCode { get; set; }
return OuterOpcode.G2C_CreateAddressableResponse;
} }
[ProtoMember(1)] public uint ErrorCode { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class C2M_TestMessage : AMessage, IAddressableRouteMessage, IProto public partial class C2M_TestMessage : AMessage, IAddressableRouteMessage, IProto
{ {
@@ -401,7 +323,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2M_TestMessage>(); return scene.MessagePoolComponent.Rent<C2M_TestMessage>();
} }
public override void Dispose() public override void Dispose()
{ {
Tag = default; Tag = default;
@@ -409,15 +330,10 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2M_TestMessage>(this); GetScene().MessagePoolComponent.Return<C2M_TestMessage>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.C2M_TestMessage; }
public uint OpCode() [ProtoMember(1)]
{ public string Tag { get; set; }
return OuterOpcode.C2M_TestMessage;
} }
[ProtoMember(1)] public string Tag { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class C2M_TestRequest : AMessage, IAddressableRouteRequest, IProto public partial class C2M_TestRequest : AMessage, IAddressableRouteRequest, IProto
{ {
@@ -425,7 +341,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2M_TestRequest>(); return scene.MessagePoolComponent.Rent<C2M_TestRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
Tag = default; Tag = default;
@@ -433,17 +348,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2M_TestRequest>(this); GetScene().MessagePoolComponent.Return<C2M_TestRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public M2C_TestResponse ResponseType { get; set; } public M2C_TestResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2M_TestRequest; }
public uint OpCode() [ProtoMember(1)]
{ public string Tag { get; set; }
return OuterOpcode.C2M_TestRequest;
} }
[ProtoMember(1)] public string Tag { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class M2C_TestResponse : AMessage, IAddressableRouteResponse, IProto public partial class M2C_TestResponse : AMessage, IAddressableRouteResponse, IProto
{ {
@@ -451,7 +361,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<M2C_TestResponse>(); return scene.MessagePoolComponent.Rent<M2C_TestResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -460,16 +369,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<M2C_TestResponse>(this); GetScene().MessagePoolComponent.Return<M2C_TestResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.M2C_TestResponse; }
public uint OpCode() [ProtoMember(1)]
{ public string Tag { get; set; }
return OuterOpcode.M2C_TestResponse; [ProtoMember(2)]
public uint ErrorCode { get; set; }
} }
[ProtoMember(1)] public string Tag { get; set; }
[ProtoMember(2)] public uint ErrorCode { get; set; }
}
/// <summary> /// <summary>
/// 通知Gate服务器创建一个Chat的Route连接 /// 通知Gate服务器创建一个Chat的Route连接
/// </summary> /// </summary>
@@ -480,22 +385,16 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2G_CreateChatRouteRequest>(); return scene.MessagePoolComponent.Rent<C2G_CreateChatRouteRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
#if FANTASY_NET || FANTASY_UNITY #if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<C2G_CreateChatRouteRequest>(this); GetScene().MessagePoolComponent.Return<C2G_CreateChatRouteRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public G2C_CreateChatRouteResponse ResponseType { get; set; } public G2C_CreateChatRouteResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2G_CreateChatRouteRequest; }
public uint OpCode()
{
return OuterOpcode.C2G_CreateChatRouteRequest;
} }
}
[ProtoContract] [ProtoContract]
public partial class G2C_CreateChatRouteResponse : AMessage, IResponse, IProto public partial class G2C_CreateChatRouteResponse : AMessage, IResponse, IProto
{ {
@@ -503,7 +402,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<G2C_CreateChatRouteResponse>(); return scene.MessagePoolComponent.Rent<G2C_CreateChatRouteResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -511,15 +409,10 @@ namespace NBC
GetScene().MessagePoolComponent.Return<G2C_CreateChatRouteResponse>(this); GetScene().MessagePoolComponent.Return<G2C_CreateChatRouteResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.G2C_CreateChatRouteResponse; }
public uint OpCode() [ProtoMember(1)]
{ public uint ErrorCode { get; set; }
return OuterOpcode.G2C_CreateChatRouteResponse;
} }
[ProtoMember(1)] public uint ErrorCode { get; set; }
}
/// <summary> /// <summary>
/// 发送一个Route消息给Chat /// 发送一个Route消息给Chat
/// </summary> /// </summary>
@@ -530,7 +423,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2Chat_TestMessage>(); return scene.MessagePoolComponent.Rent<C2Chat_TestMessage>();
} }
public override void Dispose() public override void Dispose()
{ {
Tag = default; Tag = default;
@@ -538,16 +430,12 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2Chat_TestMessage>(this); GetScene().MessagePoolComponent.Return<C2Chat_TestMessage>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.C2Chat_TestMessage; }
public uint OpCode() [ProtoIgnore]
{ public int RouteType => NBC.RouteType.ChatRoute;
return OuterOpcode.C2Chat_TestMessage; [ProtoMember(1)]
public string Tag { get; set; }
} }
[ProtoIgnore] public int RouteType => NBC.RouteType.ChatRoute;
[ProtoMember(1)] public string Tag { get; set; }
}
/// <summary> /// <summary>
/// 发送一个RPCRoute消息给Chat /// 发送一个RPCRoute消息给Chat
/// </summary> /// </summary>
@@ -558,7 +446,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<C2Chat_TestMessageRequest>(); return scene.MessagePoolComponent.Rent<C2Chat_TestMessageRequest>();
} }
public override void Dispose() public override void Dispose()
{ {
Tag = default; Tag = default;
@@ -566,18 +453,14 @@ namespace NBC
GetScene().MessagePoolComponent.Return<C2Chat_TestMessageRequest>(this); GetScene().MessagePoolComponent.Return<C2Chat_TestMessageRequest>(this);
#endif #endif
} }
[ProtoIgnore]
[ProtoIgnore] public Chat2C_TestMessageResponse ResponseType { get; set; } public Chat2C_TestMessageResponse ResponseType { get; set; }
public uint OpCode() { return OuterOpcode.C2Chat_TestMessageRequest; }
public uint OpCode() [ProtoIgnore]
{ public int RouteType => NBC.RouteType.ChatRoute;
return OuterOpcode.C2Chat_TestMessageRequest; [ProtoMember(1)]
public string Tag { get; set; }
} }
[ProtoIgnore] public int RouteType => NBC.RouteType.ChatRoute;
[ProtoMember(1)] public string Tag { get; set; }
}
[ProtoContract] [ProtoContract]
public partial class Chat2C_TestMessageResponse : AMessage, ICustomRouteResponse, IProto public partial class Chat2C_TestMessageResponse : AMessage, ICustomRouteResponse, IProto
{ {
@@ -585,7 +468,6 @@ namespace NBC
{ {
return scene.MessagePoolComponent.Rent<Chat2C_TestMessageResponse>(); return scene.MessagePoolComponent.Rent<Chat2C_TestMessageResponse>();
} }
public override void Dispose() public override void Dispose()
{ {
ErrorCode = default; ErrorCode = default;
@@ -594,13 +476,10 @@ namespace NBC
GetScene().MessagePoolComponent.Return<Chat2C_TestMessageResponse>(this); GetScene().MessagePoolComponent.Return<Chat2C_TestMessageResponse>(this);
#endif #endif
} }
public uint OpCode() { return OuterOpcode.Chat2C_TestMessageResponse; }
public uint OpCode() [ProtoMember(1)]
{ public string Tag { get; set; }
return OuterOpcode.Chat2C_TestMessageResponse; [ProtoMember(2)]
} public uint ErrorCode { get; set; }
[ProtoMember(1)] public string Tag { get; set; }
[ProtoMember(2)] public uint ErrorCode { get; set; }
} }
} }

View File

@@ -1,2 +1,11 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: cf5bc579defd25640b8f277220459410 guid: ac16629ba2ddb4832bfc3548b7a92da0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,2 +1,11 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: dc84d27ae0bdf764fb50b6d543cbcf7e guid: 79e8bd7cb8ff94462a0108fac5149a46
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,2 +1,11 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 76b668cc0db30b34ab2a64d695b14ac4 guid: 93ff0f8f28d294cdab3c6346d873065d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using UnityEngine; using UnityEngine;
namespace NBC namespace NBC
@@ -73,10 +74,34 @@ namespace NBC
private async FTask StartAsync() private async FTask StartAsync()
{ {
// 初始化框架 // 初始化框架
await NBC.Platform.Unity.Entry.Initialize(GetType().Assembly); var assemblies = AppDomain.CurrentDomain.GetAssemblies();
List<System.Reflection.Assembly> loadAssemblies = new List<System.Reflection.Assembly>();
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); _scene = await Scene.Create(SceneRuntimeMode.MainThread);
UI = _scene.AddComponent<UIComponent>(); UI = _scene.AddComponent<UIComponent>();
OnInitialized?.Invoke(); 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.");
}
} }
} }

View File

@@ -72,8 +72,9 @@ namespace NBC.Network.Interface
private void LoadInner(long assemblyIdentity) private void LoadInner(long assemblyIdentity)
{ {
var nmsl = AssemblySystem.ForEach(assemblyIdentity, typeof(IMessage));
// 遍历所有实现了IMessage接口的类型获取OpCode并添加到_networkProtocols字典中 // 遍历所有实现了IMessage接口的类型获取OpCode并添加到_networkProtocols字典中
foreach (var type in AssemblySystem.ForEach(assemblyIdentity, typeof(IMessage))) foreach (var type in nmsl)
{ {
var obj = (IMessage) Activator.CreateInstance(type); var obj = (IMessage) Activator.CreateInstance(type);
var opCode = obj.OpCode(); var opCode = obj.OpCode();

View File

@@ -231,6 +231,7 @@ namespace NBC.PacketParser
var memoryStreamLength = 0; var memoryStreamLength = 0;
var messageType = message.GetType(); var messageType = message.GetType();
var memoryStream = Network.MemoryStreamBufferPool.RentMemoryStream(MemoryStreamBufferSource.Pack); var memoryStream = Network.MemoryStreamBufferPool.RentMemoryStream(MemoryStreamBufferSource.Pack);
var nmsl = message.OpCode();
OpCodeIdStruct opCodeIdStruct = message.OpCode(); OpCodeIdStruct opCodeIdStruct = message.OpCode();
memoryStream.Seek(Packet.OuterPacketHeadLength, SeekOrigin.Begin); memoryStream.Seek(Packet.OuterPacketHeadLength, SeekOrigin.Begin);

View File

@@ -5,6 +5,7 @@ using Assets.Scripts.Hotfix;
using FairyGUI; using FairyGUI;
using NBC; using NBC;
using NBC.Network; using NBC.Network;
using NBC.Platform.Unity;
using UnityEngine; using UnityEngine;
using UnityEngine.Audio; using UnityEngine.Audio;
using UnityEngine.Video; using UnityEngine.Video;
@@ -150,18 +151,31 @@ namespace NBF
private async FTask OnLoginButtonClick() private async FTask OnLoginButtonClick()
{ {
// NBC.Platform.Unity.Entry.Initialize(GetType().Assembly);
// 根据用户名来选择目标的鉴权服务器 // 根据用户名来选择目标的鉴权服务器
// 根据鉴权服务器地址来创建一个新的网络会话 // 根据鉴权服务器地址来创建一个新的网络会话
_session = SessionHelper.CreateSession(App.Main, "127.0.0.1:20001", OnConnectComplete, _session = SessionHelper.CreateSession(App.Main, "127.0.0.1:20001", OnConnectComplete,
OnConnectFail, OnConnectFail,
OnConnectDisconnect); 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() var response = (A2C_LoginResponse)await _session.Call(new C2A_LoginRequest()
{ {
Username = "test001", Username = acc,
Password = "test001", Password = acc,
LoginType = 1 LoginType = 1
}); });
if (response.ErrorCode != 0) if (response.ErrorCode != 0)
{ {
Log.Error($"登录发生错误{response.ErrorCode}"); Log.Error($"登录发生错误{response.ErrorCode}");

View File

@@ -12,6 +12,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AKeyCode_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F021f30a9a92b48ce98ae6b39956dd76a1df600_003Fd1_003F01a95d3a_003FKeyCode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AKeyCode_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F021f30a9a92b48ce98ae6b39956dd76a1df600_003Fd1_003F01a95d3a_003FKeyCode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_00601_002Ecs_002Fl_003AC_0021_003FUsers_003Fbob_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F314938d17f3848e8ac683e11b27f62ee46ae00_003Fe8_003F01e5a04a_003FList_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AList_00601_002Ecs_002Fl_003AC_0021_003FUsers_003Fbob_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F314938d17f3848e8ac683e11b27f62ee46ae00_003Fe8_003F01e5a04a_003FList_00601_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AObject_002Ecs_002Fl_003AC_0021_003FUsers_003Fbob_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F021f30a9a92b48ce98ae6b39956dd76a1df600_003F35_003F4c34802c_003FObject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AObject_002Ecs_002Fl_003AC_0021_003FUsers_003Fbob_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F021f30a9a92b48ce98ae6b39956dd76a1df600_003F35_003F4c34802c_003FObject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AObject_002Ecs_002Fl_003AC_0021_003FUsers_003Fbob_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F314938d17f3848e8ac683e11b27f62ee46ae00_003F0d_003F47ff7f51_003FObject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APhysics_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F03ef825315384b1cab81c4b53eb03d922ac00_003Fc6_003F12ad2f00_003FPhysics_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003APhysics_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F03ef825315384b1cab81c4b53eb03d922ac00_003Fc6_003F12ad2f00_003FPhysics_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARect_002Ecs_002Fl_003AC_0021_003FUsers_003Fbob_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F021f30a9a92b48ce98ae6b39956dd76a1df600_003F42_003F3681f1e8_003FRect_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARect_002Ecs_002Fl_003AC_0021_003FUsers_003Fbob_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E1_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F021f30a9a92b48ce98ae6b39956dd76a1df600_003F42_003F3681f1e8_003FRect_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARenderChain_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb4f75f0eb2d14004826911645c6175d61fbe00_003Fde_003Fedac53d9_003FRenderChain_002Ecs/@EntryIndexedValue">ForceIncluded</s:String> <s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARenderChain_002Ecs_002Fl_003AC_0021_003FUsers_003F60527_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb4f75f0eb2d14004826911645c6175d61fbe00_003Fde_003Fedac53d9_003FRenderChain_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>