放放风
This commit is contained in:
3
Assets/Scripts/Generate.meta
Normal file
3
Assets/Scripts/Generate.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 418928520eda48558d6ff3350d301e78
|
||||
timeCreated: 1752655646
|
||||
8
Assets/Scripts/Generate/NetworkProtocol.meta
Normal file
8
Assets/Scripts/Generate/NetworkProtocol.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28af371d580930a4682dfc9be6deec1d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
606
Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs
Normal file
606
Assets/Scripts/Generate/NetworkProtocol/OuterMessage.cs
Normal file
@@ -0,0 +1,606 @@
|
||||
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<C2A_RegisterRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Username = default;
|
||||
Password = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2A_RegisterRequest>(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<A2C_RegisterResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<A2C_RegisterResponse>(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<C2A_LoginRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Username = default;
|
||||
Password = default;
|
||||
LoginType = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2A_LoginRequest>(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<A2C_LoginResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
ToKen = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<A2C_LoginResponse>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
public uint OpCode()
|
||||
{
|
||||
return OuterOpcode.A2C_LoginResponse;
|
||||
}
|
||||
|
||||
[ProtoMember(1)] public string ToKen { get; set; }
|
||||
[ProtoMember(2)] public uint ErrorCode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 客户端登录到Gate服务器
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class C2G_LoginRequest : AMessage, IRequest, IProto
|
||||
{
|
||||
public static C2G_LoginRequest Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<C2G_LoginRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ToKen = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2G_LoginRequest>(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<G2C_LoginResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
GameAccountInfo = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<G2C_LoginResponse>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
public uint OpCode()
|
||||
{
|
||||
return OuterOpcode.G2C_LoginResponse;
|
||||
}
|
||||
|
||||
[ProtoMember(1)] public GameAccountInfo GameAccountInfo { get; set; }
|
||||
[ProtoMember(2)] public uint ErrorCode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知客户端重复登录
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class G2C_RepeatLogin : AMessage, IMessage, IProto
|
||||
{
|
||||
public static G2C_RepeatLogin Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<G2C_RepeatLogin>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<G2C_RepeatLogin>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
public uint OpCode()
|
||||
{
|
||||
return OuterOpcode.G2C_RepeatLogin;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GameAccount实体类
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class GameAccountInfo : AMessage, IProto
|
||||
{
|
||||
public static GameAccountInfo Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<GameAccountInfo>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
CreateTime = default;
|
||||
LoginTime = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<GameAccountInfo>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
[ProtoMember(1)] public long CreateTime { get; set; }
|
||||
[ProtoMember(2)] public long LoginTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拿到当前账号的信息
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class C2G_GetAccountInfoRequest : AMessage, IRequest, IProto
|
||||
{
|
||||
public static C2G_GetAccountInfoRequest Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<C2G_GetAccountInfoRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2G_GetAccountInfoRequest>(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<G2C_GetAccountInfoResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
GameAccountInfo = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<G2C_GetAccountInfoResponse>(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<C2G_TestMessage>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2G_TestMessage>(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<C2G_TestRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2G_TestRequest>(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<G2C_TestResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<G2C_TestResponse>(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<C2G_CreateAddressableRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2G_CreateAddressableRequest>(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<G2C_CreateAddressableResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<G2C_CreateAddressableResponse>(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<C2M_TestMessage>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2M_TestMessage>(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<C2M_TestRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2M_TestRequest>(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<M2C_TestResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<M2C_TestResponse>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
public uint OpCode()
|
||||
{
|
||||
return OuterOpcode.M2C_TestResponse;
|
||||
}
|
||||
|
||||
[ProtoMember(1)] public string Tag { get; set; }
|
||||
[ProtoMember(2)] public uint ErrorCode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知Gate服务器创建一个Chat的Route连接
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class C2G_CreateChatRouteRequest : AMessage, IRequest, IProto
|
||||
{
|
||||
public static C2G_CreateChatRouteRequest Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<C2G_CreateChatRouteRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2G_CreateChatRouteRequest>(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<G2C_CreateChatRouteResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<G2C_CreateChatRouteResponse>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
public uint OpCode()
|
||||
{
|
||||
return OuterOpcode.G2C_CreateChatRouteResponse;
|
||||
}
|
||||
|
||||
[ProtoMember(1)] public uint ErrorCode { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送一个Route消息给Chat
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class C2Chat_TestMessage : AMessage, ICustomRouteMessage, IProto
|
||||
{
|
||||
public static C2Chat_TestMessage Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<C2Chat_TestMessage>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2Chat_TestMessage>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
public uint OpCode()
|
||||
{
|
||||
return OuterOpcode.C2Chat_TestMessage;
|
||||
}
|
||||
|
||||
[ProtoIgnore] public int RouteType => NBC.RouteType.ChatRoute;
|
||||
[ProtoMember(1)] public string Tag { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送一个RPCRoute消息给Chat
|
||||
/// </summary>
|
||||
[ProtoContract]
|
||||
public partial class C2Chat_TestMessageRequest : AMessage, ICustomRouteRequest, IProto
|
||||
{
|
||||
public static C2Chat_TestMessageRequest Create(Scene scene)
|
||||
{
|
||||
return scene.MessagePoolComponent.Rent<C2Chat_TestMessageRequest>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<C2Chat_TestMessageRequest>(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<Chat2C_TestMessageResponse>();
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
ErrorCode = default;
|
||||
Tag = default;
|
||||
#if FANTASY_NET || FANTASY_UNITY
|
||||
GetScene().MessagePoolComponent.Return<Chat2C_TestMessageResponse>(this);
|
||||
#endif
|
||||
}
|
||||
|
||||
public uint OpCode()
|
||||
{
|
||||
return OuterOpcode.Chat2C_TestMessageResponse;
|
||||
}
|
||||
|
||||
[ProtoMember(1)] public string Tag { get; set; }
|
||||
[ProtoMember(2)] public uint ErrorCode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf5bc579defd25640b8f277220459410
|
||||
28
Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs
Normal file
28
Assets/Scripts/Generate/NetworkProtocol/OuterOpcode.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
namespace NBC
|
||||
{
|
||||
public static partial class OuterOpcode
|
||||
{
|
||||
public const uint C2A_RegisterRequest = 268445457;
|
||||
public const uint A2C_RegisterResponse = 402663185;
|
||||
public const uint C2A_LoginRequest = 268445458;
|
||||
public const uint A2C_LoginResponse = 402663186;
|
||||
public const uint C2G_LoginRequest = 268445459;
|
||||
public const uint G2C_LoginResponse = 402663187;
|
||||
public const uint G2C_RepeatLogin = 134227729;
|
||||
public const uint C2G_GetAccountInfoRequest = 268445460;
|
||||
public const uint G2C_GetAccountInfoResponse = 402663188;
|
||||
public const uint C2G_TestMessage = 134227730;
|
||||
public const uint C2G_TestRequest = 268445461;
|
||||
public const uint G2C_TestResponse = 402663189;
|
||||
public const uint C2G_CreateAddressableRequest = 268445462;
|
||||
public const uint G2C_CreateAddressableResponse = 402663190;
|
||||
public const uint C2M_TestMessage = 1342187281;
|
||||
public const uint C2M_TestRequest = 1476405009;
|
||||
public const uint M2C_TestResponse = 1610622737;
|
||||
public const uint C2G_CreateChatRouteRequest = 268445463;
|
||||
public const uint G2C_CreateChatRouteResponse = 402663191;
|
||||
public const uint C2Chat_TestMessage = 2147493649;
|
||||
public const uint C2Chat_TestMessageRequest = 2281711377;
|
||||
public const uint Chat2C_TestMessageResponse = 2415929105;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc84d27ae0bdf764fb50b6d543cbcf7e
|
||||
18
Assets/Scripts/Generate/NetworkProtocol/RoamingType.cs
Normal file
18
Assets/Scripts/Generate/NetworkProtocol/RoamingType.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Collections.Generic;
|
||||
namespace NBC
|
||||
{
|
||||
// Roaming协议定义(需要定义10000以上、因为10000以内的框架预留)
|
||||
public static class RoamingType
|
||||
{
|
||||
public const int MapRoamingType = 10001;
|
||||
public const int ChatRoamingType = 10002;
|
||||
public static IEnumerable<int> RoamingTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return 10001;
|
||||
yield return 10002;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61409fb8349e78a4ca1db7e0b5342687
|
||||
9
Assets/Scripts/Generate/NetworkProtocol/RouteType.cs
Normal file
9
Assets/Scripts/Generate/NetworkProtocol/RouteType.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace NBC
|
||||
{
|
||||
// Route协议定义(需要定义1000以上、因为1000以内的框架预留)
|
||||
public static class RouteType
|
||||
{
|
||||
public const int GateRoute = 1001; // Gate
|
||||
public const int ChatRoute = 1002; // Chat
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76b668cc0db30b34ab2a64d695b14ac4
|
||||
3
Assets/Scripts/Net.meta
Normal file
3
Assets/Scripts/Net.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5af9172d15de48549ab5e6d2fc4f39a2
|
||||
timeCreated: 1752656726
|
||||
8
Assets/Scripts/Net/Entity.meta
Normal file
8
Assets/Scripts/Net/Entity.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74ec0aa87eeeae1429e7ed1dcd09f3ed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Assets.Scripts.Entity
|
||||
{
|
||||
public class AuthenticationSelectComponent : NBC.Entitas.Entity
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d25be39e48b564e35ad8425c9636ac2e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Net/Entity/JWT.meta
Normal file
8
Assets/Scripts/Net/Entity/JWT.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2b302f418e564f9bb7b2b53ac8e8194
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Scripts/Net/Entity/JWT/JWTParseComponent.cs
Normal file
17
Assets/Scripts/Net/Entity/JWT/JWTParseComponent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace Assets.Scripts.Entity
|
||||
{
|
||||
public sealed class Payload
|
||||
{
|
||||
public long aId { get; set; }
|
||||
public string Address { get; set; }
|
||||
public uint SceneId { get; set; }
|
||||
public int exp { get; set; }
|
||||
public string iss { get; set; }
|
||||
public string aud { get; set; }
|
||||
}
|
||||
|
||||
public sealed class JWTParseComponent : NBC.Entitas.Entity
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Net/Entity/JWT/JWTParseComponent.cs.meta
Normal file
11
Assets/Scripts/Net/Entity/JWT/JWTParseComponent.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b961d3db251a549139e44f247fff06f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Net/Hotfix.meta
Normal file
8
Assets/Scripts/Net/Hotfix.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50a991bccd12a0a4d9495db025c6fb78
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Scripts/Net/Hotfix/.DS_Store
vendored
Normal file
BIN
Assets/Scripts/Net/Hotfix/.DS_Store
vendored
Normal file
Binary file not shown.
8
Assets/Scripts/Net/Hotfix/Handler.meta
Normal file
8
Assets/Scripts/Net/Hotfix/Handler.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0f4856e6f88e4e0490a5ec736aa974a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/Net/Hotfix/Handler/G2C_RepeatLoginHandler.cs
Normal file
16
Assets/Scripts/Net/Hotfix/Handler/G2C_RepeatLoginHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using NBC;
|
||||
using NBC.Async;
|
||||
using NBC.Network;
|
||||
using NBC.Network.Interface;
|
||||
|
||||
namespace Assets.Scripts.Hotfix
|
||||
{
|
||||
public sealed class G2C_RepeatLoginHandler : Message<G2C_RepeatLogin>
|
||||
{
|
||||
protected override async FTask Run(Session session, G2C_RepeatLogin message)
|
||||
{
|
||||
Log.Debug("客户端重复登录了");
|
||||
await FTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7624fabae6664a6c9c9ebccebba4450
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Net/Hotfix/System.meta
Normal file
8
Assets/Scripts/Net/Hotfix/System.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3e31ce18df8044408957b2960698dc5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Entity;
|
||||
using NBC.Helper;
|
||||
|
||||
namespace Assets.Scripts.Hotfix
|
||||
{
|
||||
public static class AuthenticationSelectComponentSystem
|
||||
{
|
||||
private static readonly List<string> AuthenticationList = new List<string>()
|
||||
{
|
||||
"127.0.0.1:20001", "127.0.0.1:20002", "127.0.0.1:20003"
|
||||
};
|
||||
|
||||
public static string Select(this AuthenticationSelectComponent self, string userName)
|
||||
{
|
||||
var userNameHashCode = HashCodeHelper.MurmurHash3(userName);
|
||||
var authenticationListIndex = userNameHashCode % AuthenticationList.Count;
|
||||
// 按照现在的情况下,这个模出的值只会是0 - 3
|
||||
return AuthenticationList[(int)authenticationListIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 282ab32bfd2314add934876696504a36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Net/Hotfix/System/JWT.meta
Normal file
8
Assets/Scripts/Net/Hotfix/System/JWT.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c7d4cc51480743d99ae9f1208d7c727
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using Assets.Scripts.Entity;
|
||||
using NBC;
|
||||
using NBC.Helper;
|
||||
|
||||
namespace Assets.Scripts.Hotfix
|
||||
{
|
||||
public static class JWTParseComponentSystem
|
||||
{
|
||||
//payload:{"aId":433552570364198912,"Address":"127.0.0.1:8080","exp":1729842327,"iss":"Fantasy","aud":"Fantasy"}
|
||||
public static bool Parse(this JWTParseComponent self, string toKen, out Payload payloadData)
|
||||
{
|
||||
payloadData = null;
|
||||
|
||||
try
|
||||
{
|
||||
// JWT通常是由三个部分组成的,Header,Payload,Signature。
|
||||
var tokens = toKen.Split('.');
|
||||
|
||||
if (tokens.Length != 3)
|
||||
{
|
||||
Log.Error("Invalid JWT token");
|
||||
return false;
|
||||
}
|
||||
// JWT的Payload不是标准的Base64格式,因为咱们C#的Convert要求是一个标准的Base64格式。
|
||||
// JWT的Payload是Base64URL格式,它里面的"-"替代成了"+","_"替代成了"/",需要把这些给还原成Base64格式
|
||||
var basePayload = tokens[1].Replace('-', '+').Replace('_', '/');
|
||||
// 因为Base64的编码长度需要是4的倍数,如果不是的话咱们需要把这个长度用=来填充,使其长度符合要求
|
||||
switch (basePayload.Length % 4)
|
||||
{
|
||||
// case 0:
|
||||
// {
|
||||
// // 如果这个余数是0,那就表示长度已经是4的倍数,那就没必要处理了。
|
||||
// break;
|
||||
// }
|
||||
// case 1:
|
||||
// {
|
||||
// // 如果这个余数是1,那就表示这个Base64格式是不正确的,不是咱们发放的token。
|
||||
// // 这样情况下,也不需要处理了。
|
||||
// break;
|
||||
// }
|
||||
case 2:
|
||||
{
|
||||
basePayload +="==";
|
||||
break;
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
basePayload +="=";
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 将修复后的字符串解码为数组
|
||||
var basePayloadBytes = Convert.FromBase64String(basePayload);
|
||||
var payload = System.Text.Encoding.UTF8.GetString(basePayloadBytes);
|
||||
payloadData = JsonHelper.Deserialize<Payload>(payload);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e998e2344b9894f7c9f40b04302e2765
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/Scripts/Net/Hotfix/System/SessionHelper.cs
Normal file
30
Assets/Scripts/Net/Hotfix/System/SessionHelper.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using NBC;
|
||||
using NBC.Network;
|
||||
|
||||
namespace Assets.Scripts.Hotfix
|
||||
{
|
||||
public static class SessionHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建一个网络会话
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="address">远程服务器地址</param>
|
||||
/// <param name="onConnectComplete">当连接成功执行的委托,可为空</param>
|
||||
/// <param name="onConnectFail">当连接超时或失败执行的委托,可为空</param>
|
||||
/// <param name="onConnectDisconnect">当连接断开执行的委托,可为空</param>
|
||||
/// <returns></returns>
|
||||
public static Session CreateSession(Scene scene, string address, Action onConnectComplete, Action onConnectFail,
|
||||
Action onConnectDisconnect)
|
||||
{
|
||||
return scene.Connect(
|
||||
address,
|
||||
NetworkProtocolType.KCP,
|
||||
onConnectComplete,
|
||||
onConnectFail,
|
||||
onConnectDisconnect,
|
||||
false, 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Net/Hotfix/System/SessionHelper.cs.meta
Normal file
11
Assets/Scripts/Net/Hotfix/System/SessionHelper.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f497ae44af4c041f5acc659665ca26fc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
30
Assets/Scripts/SessionHelper.cs
Normal file
30
Assets/Scripts/SessionHelper.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using NBC;
|
||||
using NBC.Network;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public static class SessionHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建一个网络会话
|
||||
/// </summary>
|
||||
/// <param name="scene"></param>
|
||||
/// <param name="address">远程服务器地址</param>
|
||||
/// <param name="onConnectComplete">当连接成功执行的委托,可为空</param>
|
||||
/// <param name="onConnectFail">当连接超时或失败执行的委托,可为空</param>
|
||||
/// <param name="onConnectDisconnect">当连接断开执行的委托,可为空</param>
|
||||
/// <returns></returns>
|
||||
public static Session CreateSession(Scene scene, string address, Action onConnectComplete, Action onConnectFail,
|
||||
Action onConnectDisconnect)
|
||||
{
|
||||
return scene.Connect(
|
||||
address,
|
||||
NetworkProtocolType.KCP,
|
||||
onConnectComplete,
|
||||
onConnectFail,
|
||||
onConnectDisconnect,
|
||||
false, 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SessionHelper.cs.meta
Normal file
3
Assets/Scripts/SessionHelper.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 55c68672713040e4978ccb0e17564338
|
||||
timeCreated: 1752656502
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Scripts.Entity;
|
||||
using Assets.Scripts.Hotfix;
|
||||
using FairyGUI;
|
||||
using NBC;
|
||||
using NBC.Network;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
using UnityEngine.Video;
|
||||
@@ -135,6 +138,78 @@ namespace NBF
|
||||
// Fishing.Inst.Go(1);
|
||||
// SettingPanel.Show();
|
||||
// HomePanel.Show();
|
||||
|
||||
//测试登录
|
||||
OnLoginButtonClick().Coroutine();
|
||||
}
|
||||
|
||||
|
||||
#region 登录测试
|
||||
|
||||
private Session _session;
|
||||
|
||||
private async FTask OnLoginButtonClick()
|
||||
{
|
||||
// 根据用户名来选择目标的鉴权服务器
|
||||
// 根据鉴权服务器地址来创建一个新的网络会话
|
||||
_session = SessionHelper.CreateSession(App.Main, "127.0.0.1:20001", OnConnectComplete,
|
||||
OnConnectFail,
|
||||
OnConnectDisconnect);
|
||||
// 发送登录的请求给服务器
|
||||
var response = (A2C_LoginResponse)await _session.Call(new C2A_LoginRequest()
|
||||
{
|
||||
Username = "test001",
|
||||
Password = "test001",
|
||||
LoginType = 1
|
||||
});
|
||||
if (response.ErrorCode != 0)
|
||||
{
|
||||
Log.Error($"登录发生错误{response.ErrorCode}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!App.Main.GetComponent<JWTParseComponent>().Parse(response.ToKen, out var payload))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 根据ToKen返回的Address登录到Gate服务器
|
||||
_session = SessionHelper.CreateSession(App.Main, payload.Address, OnConnectComplete, OnConnectFail,
|
||||
OnConnectDisconnect);
|
||||
// 发送登录请求到Gate服务器
|
||||
var loginResponse = (G2C_LoginResponse)await _session.Call(new C2G_LoginRequest()
|
||||
{
|
||||
ToKen = response.ToKen
|
||||
});
|
||||
if (loginResponse.ErrorCode != 0)
|
||||
{
|
||||
Log.Error($"登录发生错误{loginResponse.ErrorCode}");
|
||||
return;
|
||||
}
|
||||
|
||||
Log.Debug(
|
||||
$"登录到Gate服务器成功!LoginTime:{loginResponse.GameAccountInfo.LoginTime} CreateTime:{loginResponse.GameAccountInfo.CreateTime}");
|
||||
}
|
||||
|
||||
private void OnConnectComplete()
|
||||
{
|
||||
Log.Debug("连接成功");
|
||||
// 添加心跳组件给Session。
|
||||
// Start(2000)就是2000毫秒。
|
||||
_session.AddComponent<SessionHeartbeatComponent>().Start(2000);
|
||||
}
|
||||
|
||||
private void OnConnectFail()
|
||||
{
|
||||
Log.Debug("连接失败");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private void OnConnectDisconnect()
|
||||
{
|
||||
Log.Debug("连接断开");
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
|
||||
Reference in New Issue
Block a user