diff --git a/Entity/AssemblyHelper.cs b/Entity/AssemblyHelper.cs index cac01c5..ae347d3 100644 --- a/Entity/AssemblyHelper.cs +++ b/Entity/AssemblyHelper.cs @@ -1,7 +1,7 @@ using System.Reflection; using System.Runtime.Loader; -namespace Fantasy +namespace NB { public static class AssemblyHelper { diff --git a/Entity/Authentication/AuthenticationComponent.cs b/Entity/Authentication/AuthenticationComponent.cs index 288d748..e9868e2 100644 --- a/Entity/Authentication/AuthenticationComponent.cs +++ b/Entity/Authentication/AuthenticationComponent.cs @@ -1,6 +1,8 @@ -namespace Fantasy; +using Fantasy.Entitas; -public sealed class AuthenticationComponent : Entitas.Entity +namespace NB; + +public sealed class AuthenticationComponent : Entity { /// /// 代表当前服务器在鉴权服务器中的位置 diff --git a/Entity/Authentication/AuthenticationJwtComponent.cs b/Entity/Authentication/AuthenticationJwtComponent.cs index 1df96e7..ebc57c4 100644 --- a/Entity/Authentication/AuthenticationJwtComponent.cs +++ b/Entity/Authentication/AuthenticationJwtComponent.cs @@ -1,7 +1,7 @@ using Fantasy.Entitas; using Microsoft.IdentityModel.Tokens; -namespace Fantasy; +namespace NB; public sealed class AuthenticationJwtComponent : Entity { diff --git a/Entity/Authentication/Model/Account.cs b/Entity/Authentication/Entity/Account.cs similarity index 92% rename from Entity/Authentication/Model/Account.cs rename to Entity/Authentication/Entity/Account.cs index d988830..8982809 100644 --- a/Entity/Authentication/Model/Account.cs +++ b/Entity/Authentication/Entity/Account.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB; public sealed class Account : Entity { diff --git a/Entity/Authentication/Model/AccountCacheInfo.cs b/Entity/Authentication/Entity/AccountCacheInfo.cs similarity index 79% rename from Entity/Authentication/Model/AccountCacheInfo.cs rename to Entity/Authentication/Entity/AccountCacheInfo.cs index 5c1701a..5eafd59 100644 --- a/Entity/Authentication/Model/AccountCacheInfo.cs +++ b/Entity/Authentication/Entity/AccountCacheInfo.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB; public class AccountCacheInfo : Entity { diff --git a/Entity/Authentication/TimeOut/AccountCacheInfoTimeOut.cs b/Entity/Authentication/TimeOut/AccountCacheInfoTimeOut.cs index 7517f63..1d17765 100644 --- a/Entity/Authentication/TimeOut/AccountCacheInfoTimeOut.cs +++ b/Entity/Authentication/TimeOut/AccountCacheInfoTimeOut.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB; public class AccountCacheInfoTimeOut : Entity { diff --git a/Entity/Authentication/TimeOut/AccountTimeOut.cs b/Entity/Authentication/TimeOut/AccountTimeOut.cs index db2fe5e..d3e6029 100644 --- a/Entity/Authentication/TimeOut/AccountTimeOut.cs +++ b/Entity/Authentication/TimeOut/AccountTimeOut.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB; public class AccountTimeOut : Entity { diff --git a/Entity/Entity.csproj b/Entity/Entity.csproj index b4fb434..137382c 100644 --- a/Entity/Entity.csproj +++ b/Entity/Entity.csproj @@ -27,8 +27,6 @@ - - diff --git a/Entity/EntityTimeOutComponent.cs b/Entity/EntityTimeOutComponent.cs index d32096a..3cfd390 100644 --- a/Entity/EntityTimeOutComponent.cs +++ b/Entity/EntityTimeOutComponent.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB; public class EntityTimeOutComponent : Entity { diff --git a/Entity/Model/DB/Members/ActivityInfo.cs b/Entity/Game/Entity/ActivityInfo.cs similarity index 76% rename from Entity/Model/DB/Members/ActivityInfo.cs rename to Entity/Game/Entity/ActivityInfo.cs index 23b7f3a..42d9946 100644 --- a/Entity/Model/DB/Members/ActivityInfo.cs +++ b/Entity/Game/Entity/ActivityInfo.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class Activity : Entity { diff --git a/Entity/Model/DB/Members/BasicInfo.cs b/Entity/Game/Entity/BasicInfo.cs similarity index 95% rename from Entity/Model/DB/Members/BasicInfo.cs rename to Entity/Game/Entity/BasicInfo.cs index 787dabb..4491360 100644 --- a/Entity/Model/DB/Members/BasicInfo.cs +++ b/Entity/Game/Entity/BasicInfo.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class BasicInfo : Entity { diff --git a/Entity/Model/DB/Members/Currency.cs b/Entity/Game/Entity/Currency.cs similarity index 92% rename from Entity/Model/DB/Members/Currency.cs rename to Entity/Game/Entity/Currency.cs index c157bc4..592e240 100644 --- a/Entity/Model/DB/Members/Currency.cs +++ b/Entity/Game/Entity/Currency.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class Currency : Entity { diff --git a/Entity/Model/DB/Members/DayFlags.cs b/Entity/Game/Entity/DayFlags.cs similarity index 54% rename from Entity/Model/DB/Members/DayFlags.cs rename to Entity/Game/Entity/DayFlags.cs index 6f3055e..eaee747 100644 --- a/Entity/Model/DB/Members/DayFlags.cs +++ b/Entity/Game/Entity/DayFlags.cs @@ -1,4 +1,4 @@ -namespace Fantasy; +namespace NB.Game; public class DayFlags { diff --git a/Entity/Model/DB/Members/GamingInfo.cs b/Entity/Game/Entity/GamingInfo.cs similarity index 93% rename from Entity/Model/DB/Members/GamingInfo.cs rename to Entity/Game/Entity/GamingInfo.cs index 0b00b33..b99cbe5 100644 --- a/Entity/Model/DB/Members/GamingInfo.cs +++ b/Entity/Game/Entity/GamingInfo.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class GamingInfo : Entity { diff --git a/Entity/Model/DB/Members/Guide.cs b/Entity/Game/Entity/Guide.cs similarity index 95% rename from Entity/Model/DB/Members/Guide.cs rename to Entity/Game/Entity/Guide.cs index 8f0220a..79b2d4d 100644 --- a/Entity/Model/DB/Members/Guide.cs +++ b/Entity/Game/Entity/Guide.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class Guide : Entity { diff --git a/Entity/Model/DB/Members/Item.cs b/Entity/Game/Entity/Item.cs similarity index 80% rename from Entity/Model/DB/Members/Item.cs rename to Entity/Game/Entity/Item.cs index ccdb841..47cc505 100644 --- a/Entity/Model/DB/Members/Item.cs +++ b/Entity/Game/Entity/Item.cs @@ -1,21 +1,21 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class Item : Entity { - /// - /// 配置id - /// - public int ConfigId; - /// /// 拥有的数量 /// public int Count; /// - /// 耐久度 + /// 配置id /// - public int Durability; + public int ConfigId; + + /// + /// 是否绑定 + /// + public bool IsBind; } \ No newline at end of file diff --git a/Entity/Model/DB/Members/MapMatter.cs b/Entity/Game/Entity/MapMatter.cs similarity index 76% rename from Entity/Model/DB/Members/MapMatter.cs rename to Entity/Game/Entity/MapMatter.cs index 58beb5b..ce58057 100644 --- a/Entity/Model/DB/Members/MapMatter.cs +++ b/Entity/Game/Entity/MapMatter.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class MapMatter : Entity { diff --git a/Entity/Model/DB/Members/MissionInfo.cs b/Entity/Game/Entity/Mission.cs similarity index 76% rename from Entity/Model/DB/Members/MissionInfo.cs rename to Entity/Game/Entity/Mission.cs index d8e59ef..e298f80 100644 --- a/Entity/Model/DB/Members/MissionInfo.cs +++ b/Entity/Game/Entity/Mission.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class Mission : Entity { diff --git a/Entity/Model/Game/Player.cs b/Entity/Game/Entity/Player.cs similarity index 100% rename from Entity/Model/Game/Player.cs rename to Entity/Game/Entity/Player.cs diff --git a/Entity/Model/DB/Members/Skill.cs b/Entity/Game/Entity/Skill.cs similarity index 75% rename from Entity/Model/DB/Members/Skill.cs rename to Entity/Game/Entity/Skill.cs index db1c645..2c10135 100644 --- a/Entity/Model/DB/Members/Skill.cs +++ b/Entity/Game/Entity/Skill.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class Skill : Entity { diff --git a/Entity/Model/DB/UserInfo.cs b/Entity/Game/Entity/UserInfo.cs similarity index 91% rename from Entity/Model/DB/UserInfo.cs rename to Entity/Game/Entity/UserInfo.cs index a29d331..537ac07 100644 --- a/Entity/Model/DB/UserInfo.cs +++ b/Entity/Game/Entity/UserInfo.cs @@ -1,6 +1,7 @@ using Fantasy.Entitas; +using NB.Game; -namespace Fantasy; +namespace NB; public class UserInfo : Entity { @@ -28,12 +29,7 @@ public class UserInfo : Entity /// 拥有的物品 /// public List Items; - - /// - /// 鱼护 - /// - public List Fishes; - + /// /// 参与的活动 /// diff --git a/Entity/Model/DB/Members/UserStatisticsInfo.cs b/Entity/Game/Entity/UserStatisticsInfo.cs similarity index 96% rename from Entity/Model/DB/Members/UserStatisticsInfo.cs rename to Entity/Game/Entity/UserStatisticsInfo.cs index 7ea946d..289f8ee 100644 --- a/Entity/Model/DB/Members/UserStatisticsInfo.cs +++ b/Entity/Game/Entity/UserStatisticsInfo.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy; +namespace NB.Game; public class UserStatisticsInfo : Entity { diff --git a/Entity/Gate/Model/GameAccount.cs b/Entity/Gate/Entity/GameAccount.cs similarity index 95% rename from Entity/Gate/Model/GameAccount.cs rename to Entity/Gate/Entity/GameAccount.cs index 589652f..887383d 100644 --- a/Entity/Gate/Model/GameAccount.cs +++ b/Entity/Gate/Entity/GameAccount.cs @@ -1,7 +1,7 @@ using Fantasy.Entitas; using MongoDB.Bson.Serialization.Attributes; -namespace Fantasy.Gate; +namespace NB.Gate; public sealed class GameAccount : Entity { diff --git a/Entity/Gate/Model/GameAccountFlagComponent.cs b/Entity/Gate/Entity/GameAccountFlagComponent.cs similarity index 94% rename from Entity/Gate/Model/GameAccountFlagComponent.cs rename to Entity/Gate/Entity/GameAccountFlagComponent.cs index 6e01d75..679dfa1 100644 --- a/Entity/Gate/Model/GameAccountFlagComponent.cs +++ b/Entity/Gate/Entity/GameAccountFlagComponent.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy.Gate; +namespace NB.Gate; public sealed class GameAccountFlagComponent : Entity { diff --git a/Entity/Gate/GameAccountManageComponent.cs b/Entity/Gate/GameAccountManageComponent.cs index 1adab80..23172cb 100644 --- a/Entity/Gate/GameAccountManageComponent.cs +++ b/Entity/Gate/GameAccountManageComponent.cs @@ -1,6 +1,6 @@ using Fantasy.Entitas; -namespace Fantasy.Gate; +namespace NB.Gate; public sealed class GameAccountManageComponent : Entity { diff --git a/Entity/Gate/GateJWTComponent.cs b/Entity/Gate/GateJWTComponent.cs index 089a4d4..4e190ce 100644 --- a/Entity/Gate/GateJWTComponent.cs +++ b/Entity/Gate/GateJWTComponent.cs @@ -1,7 +1,7 @@ using Fantasy.Entitas; using Microsoft.IdentityModel.Tokens; -namespace Fantasy.Gate; +namespace NB.Gate; public sealed class GateJWTComponent : Entity { diff --git a/Entity/LockType.cs b/Entity/LockType.cs index c0ea4d7..9cdddc4 100644 --- a/Entity/LockType.cs +++ b/Entity/LockType.cs @@ -1,4 +1,4 @@ -namespace Fantasy; +namespace NB; public enum LockType { diff --git a/Entity/Model/DB/Members/Fish.cs b/Entity/Model/DB/Members/Fish.cs deleted file mode 100644 index afb0ff6..0000000 --- a/Entity/Model/DB/Members/Fish.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Fantasy.Entitas; - -namespace Fantasy; - -public class Fish : Entity -{ -} \ No newline at end of file diff --git a/Entity/Model/Def/ErrorCode.cs b/Entity/Model/Def/ErrorCode.cs new file mode 100644 index 0000000..277e856 --- /dev/null +++ b/Entity/Model/Def/ErrorCode.cs @@ -0,0 +1,32 @@ +namespace Fantasy; + +public class ErrorCode +{ + public const uint Successful = 0; + + /// + /// 参数有误 + /// + public const uint ErrArgs = 10001; + + /// + /// 服务器有误 + /// + public const uint ErrServer = 10002; + + /// + /// 操作太频繁 + /// + public const uint ErrFrequent = 10003; + + + /// + /// 账号已被注册 + /// + public const uint ErrAccountHave = 11001; + + /// + /// 账号或密码有误 + /// + public const uint ErrAccountOrPass = 11002; +} \ No newline at end of file diff --git a/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Message/InnerMessage.cs b/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Message/InnerMessage.cs index 643c92b..9a095a4 100644 --- a/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Message/InnerMessage.cs +++ b/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Message/InnerMessage.cs @@ -5,6 +5,7 @@ using ProtoBuf; #if FANTASY_NET using Fantasy.Network.Roaming; #endif + #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. // ReSharper disable InconsistentNaming // ReSharper disable PropertyCanBeMadeInitOnly.Global @@ -21,6 +22,7 @@ namespace Fantasy.InnerMessage return Fantasy.Network.OpCode.BenchmarkMessage; } } + [ProtoContract] public partial class BenchmarkRequest : AMessage, IRequest { @@ -28,12 +30,11 @@ namespace Fantasy.InnerMessage { return Fantasy.Network.OpCode.BenchmarkRequest; } - [ProtoIgnore] - public BenchmarkResponse ResponseType { get; set; } - [ProtoMember(1)] - public long RpcId { get; set; } + + [ProtoIgnore] public BenchmarkResponse ResponseType { get; set; } + [ProtoMember(1)] public long RpcId { get; set; } } - + [ProtoContract] public partial class BenchmarkResponse : AMessage, IResponse { @@ -41,22 +42,22 @@ namespace Fantasy.InnerMessage { return Fantasy.Network.OpCode.BenchmarkResponse; } - [ProtoMember(1)] - public long RpcId { get; set; } - [ProtoMember(2)] - public uint ErrorCode { get; set; } + + [ProtoMember(1)] public long RpcId { get; set; } + [ProtoMember(2)] public uint ErrorCode { get; set; } } + public sealed partial class Response : AMessage, IResponse { public uint OpCode() { return Fantasy.Network.OpCode.DefaultResponse; } - [ProtoMember(1)] - public long RpcId { get; set; } - [ProtoMember(2)] - public uint ErrorCode { get; set; } + + [ProtoMember(1)] public long RpcId { get; set; } + [ProtoMember(2)] public uint ErrorCode { get; set; } } + [ProtoContract] public sealed partial class RouteResponse : AMessage, IRouteResponse { @@ -64,11 +65,11 @@ namespace Fantasy.InnerMessage { return Fantasy.Network.OpCode.DefaultRouteResponse; } - [ProtoMember(1)] - public long RpcId { get; set; } - [ProtoMember(2)] - public uint ErrorCode { get; set; } + + [ProtoMember(1)] public long RpcId { get; set; } + [ProtoMember(2)] public uint ErrorCode { get; set; } } + [ProtoContract] public partial class PingRequest : AMessage, IRequest { @@ -76,12 +77,11 @@ namespace Fantasy.InnerMessage { return Fantasy.Network.OpCode.PingRequest; } - [ProtoIgnore] - public PingResponse ResponseType { get; set; } - [ProtoMember(1)] - public long RpcId { get; set; } + + [ProtoIgnore] public PingResponse ResponseType { get; set; } + [ProtoMember(1)] public long RpcId { get; set; } } - + [ProtoContract] public partial class PingResponse : AMessage, IResponse { @@ -89,231 +89,334 @@ namespace Fantasy.InnerMessage { return Fantasy.Network.OpCode.PingResponse; } - [ProtoMember(1)] - public long RpcId { get; set; } - [ProtoMember(2)] - public uint ErrorCode { get; set; } - [ProtoMember(3)] - public long Now; + + [ProtoMember(1)] public long RpcId { get; set; } + [ProtoMember(2)] public uint ErrorCode { get; set; } + [ProtoMember(3)] public long Now; } + [ProtoContract] public partial class I_AddressableAdd_Request : AMessage, IRouteRequest { - [ProtoIgnore] - public I_AddressableAdd_Response ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.AddressableAddRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } - [ProtoMember(2)] - public long RouteId { get; set; } - [ProtoMember(3)] - public bool IsLock { get; set; } + [ProtoIgnore] public I_AddressableAdd_Response ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableAddRequest; + } + + public long RouteTypeOpCode() + { + return 1; + } + + [ProtoMember(1)] public long AddressableId { get; set; } + [ProtoMember(2)] public long RouteId { get; set; } + [ProtoMember(3)] public bool IsLock { get; set; } } + [ProtoContract] public partial class I_AddressableAdd_Response : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.AddressableAddResponse; } - [ProtoMember(1)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableAddResponse; + } + + [ProtoMember(1)] public uint ErrorCode { get; set; } } + [ProtoContract] public partial class I_AddressableGet_Request : AMessage, IRouteRequest { - [ProtoIgnore] - public I_AddressableGet_Response ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.AddressableGetRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } + [ProtoIgnore] public I_AddressableGet_Response ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableGetRequest; + } + + public long RouteTypeOpCode() + { + return 1; + } + + [ProtoMember(1)] public long AddressableId { get; set; } } + [ProtoContract] public partial class I_AddressableGet_Response : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.AddressableGetResponse; } - [ProtoMember(2)] - public uint ErrorCode { get; set; } - [ProtoMember(1)] - public long RouteId { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableGetResponse; + } + + [ProtoMember(2)] public uint ErrorCode { get; set; } + [ProtoMember(1)] public long RouteId { get; set; } } + [ProtoContract] public partial class I_AddressableRemove_Request : AMessage, IRouteRequest { - [ProtoIgnore] - public I_AddressableRemove_Response ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.AddressableRemoveRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } + [ProtoIgnore] public I_AddressableRemove_Response ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableRemoveRequest; + } + + public long RouteTypeOpCode() + { + return 1; + } + + [ProtoMember(1)] public long AddressableId { get; set; } } + [ProtoContract] public partial class I_AddressableRemove_Response : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.AddressableRemoveResponse; } - [ProtoMember(1)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableRemoveResponse; + } + + [ProtoMember(1)] public uint ErrorCode { get; set; } } + [ProtoContract] public partial class I_AddressableLock_Request : AMessage, IRouteRequest { - [ProtoIgnore] - public I_AddressableLock_Response ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.AddressableLockRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } + [ProtoIgnore] public I_AddressableLock_Response ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableLockRequest; + } + + public long RouteTypeOpCode() + { + return 1; + } + + [ProtoMember(1)] public long AddressableId { get; set; } } + [ProtoContract] public partial class I_AddressableLock_Response : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.AddressableLockResponse; } - [ProtoMember(1)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableLockResponse; + } + + [ProtoMember(1)] public uint ErrorCode { get; set; } } + [ProtoContract] public partial class I_AddressableUnLock_Request : AMessage, IRouteRequest { - [ProtoIgnore] - public I_AddressableUnLock_Response ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.AddressableUnLockRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long AddressableId { get; set; } - [ProtoMember(2)] - public long RouteId { get; set; } - [ProtoMember(3)] - public string Source { get; set; } + [ProtoIgnore] public I_AddressableUnLock_Response ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableUnLockRequest; + } + + public long RouteTypeOpCode() + { + return 1; + } + + [ProtoMember(1)] public long AddressableId { get; set; } + [ProtoMember(2)] public long RouteId { get; set; } + [ProtoMember(3)] public string Source { get; set; } } + [ProtoContract] public partial class I_AddressableUnLock_Response : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.AddressableUnLockResponse; } - [ProtoMember(1)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.AddressableUnLockResponse; + } + + [ProtoMember(1)] public uint ErrorCode { get; set; } } #if FANTASY_NET [ProtoContract] public sealed class I_LinkRoamingRequest : AMessage, IRouteRequest { - [ProtoIgnore] - public I_LinkRoamingResponse ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.LinkRoamingRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long RoamingId { get; set; } - [ProtoMember(2)] - public int RoamingType { get; set; } - [ProtoMember(3)] - public long ForwardSessionRouteId { get; set; } - [ProtoMember(4)] - public long SceneRouteId { get; set; } + [ProtoIgnore] public I_LinkRoamingResponse ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.LinkRoamingRequest; + } + + public long RouteTypeOpCode() + { + return 1; + } + + [ProtoMember(1)] public long RoamingId { get; set; } + [ProtoMember(2)] public int RoamingType { get; set; } + [ProtoMember(3)] public long ForwardSessionRouteId { get; set; } + [ProtoMember(4)] public long SceneRouteId { get; set; } } + [ProtoContract] public sealed class I_LinkRoamingResponse : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.LinkRoamingResponse; } - [ProtoMember(1)] - public long TerminusId { get; set; } - [ProtoMember(2)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.LinkRoamingResponse; + } + + [ProtoMember(1)] public long TerminusId { get; set; } + [ProtoMember(2)] public uint ErrorCode { get; set; } } + [ProtoContract] public sealed class I_UnLinkRoamingRequest : AMessage, IRouteRequest { - [ProtoIgnore] - public I_UnLinkRoamingResponse ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.UnLinkRoamingRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long RoamingId { get; set; } - [ProtoMember(2)] - public bool DisposeRoaming { get; set; } + [ProtoIgnore] public I_UnLinkRoamingResponse ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.UnLinkRoamingRequest; + } + + public long RouteTypeOpCode() + { + return 1; + } + + [ProtoMember(1)] public long RoamingId { get; set; } + [ProtoMember(2)] public bool DisposeRoaming { get; set; } } + [ProtoContract] public sealed class I_UnLinkRoamingResponse : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.UnLinkRoamingResponse; } - [ProtoMember(1)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.UnLinkRoamingResponse; + } + + [ProtoMember(1)] public uint ErrorCode { get; set; } } + [ProtoContract] public partial class I_LockTerminusIdRequest : AMessage, IRouteRequest { - [ProtoIgnore] - public I_LockTerminusIdResponse ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.LockTerminusIdRequest; } - [ProtoMember(1)] - public long SessionRuntimeId { get; set; } - [ProtoMember(2)] - public int RoamingType { get; set; } + [ProtoIgnore] public I_LockTerminusIdResponse ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.LockTerminusIdRequest; + } + + [ProtoMember(1)] public long SessionRuntimeId { get; set; } + [ProtoMember(2)] public int RoamingType { get; set; } } + [ProtoContract] public partial class I_LockTerminusIdResponse : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.LockTerminusIdResponse; } - [ProtoMember(1)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.LockTerminusIdResponse; + } + + [ProtoMember(1)] public uint ErrorCode { get; set; } } + [ProtoContract] public sealed class I_UnLockTerminusIdRequest : AMessage, IRouteRequest { - [ProtoIgnore] - public I_UnLockTerminusIdResponse ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.UnLockTerminusIdRequest; } - public long RouteTypeOpCode() { return 1; } - [ProtoMember(1)] - public long SessionRuntimeId { get; set; } - [ProtoMember(2)] - public int RoamingType { get; set; } - [ProtoMember(3)] - public long TerminusId { get; set; } - [ProtoMember(4)] - public long TargetSceneRouteId { get; set; } + [ProtoIgnore] public I_UnLockTerminusIdResponse ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.UnLockTerminusIdRequest; + } + + public long RouteTypeOpCode() + { + return 1; + } + + [ProtoMember(1)] public long SessionRuntimeId { get; set; } + [ProtoMember(2)] public int RoamingType { get; set; } + [ProtoMember(3)] public long TerminusId { get; set; } + [ProtoMember(4)] public long TargetSceneRouteId { get; set; } } + [ProtoContract] public sealed class I_UnLockTerminusIdResponse : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.UnLockTerminusIdResponse; } - [ProtoMember(1)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.UnLockTerminusIdResponse; + } + + [ProtoMember(1)] public uint ErrorCode { get; set; } } + /// /// 漫游传送终端的请求 /// public partial class I_TransferTerminusRequest : AMessage, IRouteRequest { - [BsonIgnore] - public I_TransferTerminusResponse ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.TransferTerminusRequest; } + [BsonIgnore] public I_TransferTerminusResponse ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.TransferTerminusRequest; + } + public Terminus Terminus { get; set; } } + public partial class I_TransferTerminusResponse : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.TransferTerminusResponse; } + public uint OpCode() + { + return Fantasy.Network.OpCode.TransferTerminusResponse; + } + public uint ErrorCode { get; set; } } + /// /// 用于服务器之间获取漫游的TerminusId。 /// [ProtoContract] public partial class I_GetTerminusIdRequest : AMessage, IRouteRequest { - [ProtoIgnore] - public I_GetTerminusIdResponse ResponseType { get; set; } - public uint OpCode() { return Fantasy.Network.OpCode.GetTerminusIdRequest; } - [ProtoMember(1)] - public int RoamingType { get; set; } - [ProtoMember(2)] - public long SessionRuntimeId { get; set; } + [ProtoIgnore] public I_GetTerminusIdResponse ResponseType { get; set; } + + public uint OpCode() + { + return Fantasy.Network.OpCode.GetTerminusIdRequest; + } + + [ProtoMember(1)] public int RoamingType { get; set; } + [ProtoMember(2)] public long SessionRuntimeId { get; set; } } + [ProtoContract] public partial class I_GetTerminusIdResponse : AMessage, IRouteResponse { - public uint OpCode() { return Fantasy.Network.OpCode.GetTerminusIdResponse; } - [ProtoMember(1)] - public long TerminusId { get; set; } - [ProtoMember(2)] - public uint ErrorCode { get; set; } + public uint OpCode() + { + return Fantasy.Network.OpCode.GetTerminusIdResponse; + } + + [ProtoMember(1)] public long TerminusId { get; set; } + [ProtoMember(2)] public uint ErrorCode { get; set; } } #endif } \ No newline at end of file diff --git a/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Message/Scheduler/OuterMessageScheduler.cs b/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Message/Scheduler/OuterMessageScheduler.cs index 2c963ff..88d7dd9 100644 --- a/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Message/Scheduler/OuterMessageScheduler.cs +++ b/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Message/Scheduler/OuterMessageScheduler.cs @@ -53,7 +53,6 @@ namespace Fantasy.Scheduler case OpCodeType.OuterPingRequest: { // 注意心跳目前只有外网才才会有、内网之间不需要心跳。 - session.LastReceiveTime = TimeHelper.Now; _pingResponse.Now = session.LastReceiveTime; diff --git a/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Session/Session.cs b/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Session/Session.cs index fc75dea..dd2b4ea 100644 --- a/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Session/Session.cs +++ b/Fantasy/Fantasy.Net/Fantasy.Net/Runtime/Core/Network/Session/Session.cs @@ -1,4 +1,5 @@ // ReSharper disable RedundantUsingDirective + using System; using System.Collections.Generic; using System.IO; @@ -17,6 +18,7 @@ using Fantasy.Serialize; using Fantasy.Network.Route; using Fantasy.Platform.Net; using Fantasy.Network.Roaming; + #pragma warning disable CS1591 // Missing XML comment for publicly visible type or member #endif // ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract @@ -36,15 +38,18 @@ namespace Fantasy.Network { private uint _rpcId; internal long LastReceiveTime; + /// /// 关联的网络连接通道 /// internal INetworkChannel Channel { get; private set; } + /// /// 当前Session的终结点信息 /// public IPEndPoint RemoteEndPoint { get; private set; } - private ANetworkMessageScheduler NetworkMessageScheduler { get; set;} + + private ANetworkMessageScheduler NetworkMessageScheduler { get; set; } internal readonly Dictionary> RequestCallback = new(); /// /// Session的Dispose委托 @@ -54,7 +59,8 @@ namespace Fantasy.Network internal RouteComponent RouteComponent; internal SessionRoamingComponent SessionRoamingComponent; internal AddressableRouteComponent AddressableRouteComponent; - internal static Session Create(ANetworkMessageScheduler networkMessageScheduler, ANetworkServerChannel channel, NetworkTarget networkTarget) + internal static Session Create(ANetworkMessageScheduler networkMessageScheduler, ANetworkServerChannel channel, + NetworkTarget networkTarget) { var session = Entity.Create(channel.Scene, false, true); session.Channel = channel; @@ -69,6 +75,7 @@ namespace Fantasy.Network var timeOut = ProcessDefine.SessionIdleCheckerTimeout; session.AddComponent().Start(interval, timeOut); } + return session; } #endif @@ -152,7 +159,7 @@ namespace Fantasy.Network { return; } - + _rpcId = 0; LastReceiveTime = 0; Channel = null; @@ -170,11 +177,11 @@ namespace Fantasy.Network { requestCallback.SetException(new Exception($"session is dispose: {Id}")); } - + RequestCallback.Clear(); OnDispose?.Invoke(); } - + /// /// 发送一个消息 /// @@ -187,10 +194,10 @@ namespace Fantasy.Network { return; } - + Channel.Send(rpcId, routeId, null, message); } - + /// /// 发送一个消息 /// @@ -206,7 +213,7 @@ namespace Fantasy.Network Channel.Send(rpcId, routeId, null, routeMessage); } - + /// /// 发送一个RPC消息 /// @@ -219,14 +226,14 @@ namespace Fantasy.Network { return null; } - + var requestCallback = FTask.Create(); - var rpcId = ++_rpcId; + var rpcId = ++_rpcId; RequestCallback.Add(rpcId, requestCallback); Send(request, rpcId, routeId); return requestCallback; } - + /// /// 发送一个RPC消息 /// @@ -239,9 +246,9 @@ namespace Fantasy.Network { return null; } - + var requestCallback = FTask.Create(); - var rpcId = ++_rpcId; + var rpcId = ++_rpcId; RequestCallback.Add(rpcId, requestCallback); Send(request, rpcId, routeId); return requestCallback; @@ -269,4 +276,4 @@ namespace Fantasy.Network } } } -} +} \ No newline at end of file diff --git a/Hotfix/EntityHelper.cs b/Hotfix/EntityHelper.cs index 362e3f6..4a80772 100644 --- a/Hotfix/EntityHelper.cs +++ b/Hotfix/EntityHelper.cs @@ -1,11 +1,11 @@ -using System.Authentication; +using NB.Authentication; using Fantasy; using Fantasy.Async; using Fantasy.Entitas; using Fantasy.Network; // ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract -namespace System; +namespace NB; public static class EntityHelper { diff --git a/Hotfix/EntityTimeOutComponentSystem.cs b/Hotfix/EntityTimeOutComponentSystem.cs index 05fabc0..28d1e8e 100644 --- a/Hotfix/EntityTimeOutComponentSystem.cs +++ b/Hotfix/EntityTimeOutComponentSystem.cs @@ -3,7 +3,7 @@ using Fantasy.Async; using Fantasy.Entitas.Interface; using Fantasy.Helper; -namespace System.Authentication; +namespace NB.Authentication; public sealed class EntityTimeOutComponentDestroySystem : DestroySystem { diff --git a/Hotfix/OnCreateSceneEvent.cs b/Hotfix/OnCreateSceneEvent.cs index e1e0427..bb041ce 100644 --- a/Hotfix/OnCreateSceneEvent.cs +++ b/Hotfix/OnCreateSceneEvent.cs @@ -1,3 +1,4 @@ +using Fantasy; using Fantasy.Async; using Fantasy.Entitas; using Fantasy.Event; @@ -5,7 +6,7 @@ using Fantasy.Helper; using Fantasy.Serialize; using ProtoBuf; -namespace Fantasy; +namespace NB; public sealed class SubSceneTestComponent : Entity { diff --git a/Hotfix/OnSceneCreate_Init.cs b/Hotfix/OnSceneCreate_Init.cs index 4f3f203..201c2b3 100644 --- a/Hotfix/OnSceneCreate_Init.cs +++ b/Hotfix/OnSceneCreate_Init.cs @@ -1,11 +1,10 @@ -using System.Authentication; -using Fantasy; +using Fantasy; using Fantasy.Async; -using Fantasy.Authentication; using Fantasy.Event; -using Fantasy.Gate; +using NB.Authentication; +using NB.Gate; -namespace System; +namespace NB; public class OnSceneCreate_Init : AsyncEventSystem { diff --git a/Hotfix/Outer/Authentication/Handler/C2A_LoginRequestHandler.cs b/Hotfix/Outer/Authentication/Handler/C2A_LoginRequestHandler.cs index 8e80eb0..dccccb7 100644 --- a/Hotfix/Outer/Authentication/Handler/C2A_LoginRequestHandler.cs +++ b/Hotfix/Outer/Authentication/Handler/C2A_LoginRequestHandler.cs @@ -1,21 +1,46 @@ using Fantasy; using Fantasy.Async; -using Fantasy.Authentication.Jwt; using Fantasy.Network; using Fantasy.Network.Interface; using Fantasy.Platform.Net; +using NB.Authentication.Jwt; -namespace Fantasy.Authentication.Handler; +namespace NB.Authentication.Handler; public class C2A_LoginRequestHandler : MessageRPC { protected override async FTask Run(Session session, C2A_LoginRequest request, A2C_LoginResponse response, Action reply) { + if (!session.CheckInterval(2000)) + { + // 返回这个3代表操作过于频繁。 + response.ErrorCode = ErrorCode.ErrFrequent; + return; + } + + session.SetTimeout(3000); var scene = session.Scene; var result = await AuthenticationHelper.Login(scene, request.Username, request.Password); - if (result.ErrorCode == 0) + if (result.ErrorCode != ErrorCode.Successful && result.AccountId == -1) + { + //开始注册账号 + var regErrorCode = + await AuthenticationHelper.Register(session.Scene, request.Username, request.Password, "用户注册"); + if (regErrorCode != ErrorCode.Successful) + { + result.ErrorCode = regErrorCode; + } + else + { + Log.Debug($"Register 当前的服务器是:{scene.SceneConfigId}"); + //注册完毕,执行登录 + result = await AuthenticationHelper.Login(scene, request.Username, request.Password); + } + } + + if (result.ErrorCode == ErrorCode.Successful) { // 通过配置表或其他方式拿到Gate服务器组的信息 var gates = SceneConfigData.Instance.GetSceneBySceneType(SceneType.Gate); diff --git a/Hotfix/Outer/Authentication/Handler/C2A_RegisterRequestHandler.cs b/Hotfix/Outer/Authentication/Handler/C2A_RegisterRequestHandler.cs deleted file mode 100644 index 5fa3be1..0000000 --- a/Hotfix/Outer/Authentication/Handler/C2A_RegisterRequestHandler.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Fantasy; -using Fantasy.Async; -using Fantasy.Network; -using Fantasy.Network.Interface; - -namespace Fantasy.Authentication.Handler; - -public sealed class C2A_RegisterRequestHandler : MessageRPC -{ - protected override async FTask Run(Session session, C2A_RegisterRequest request, A2C_RegisterResponse response, - Action reply) - { - if (!session.CheckInterval(2000)) - { - // 返回这个3代表操作过于频繁。 - response.ErrorCode = 3; - return; - } - - session.SetTimeout(3000); - response.ErrorCode = - await AuthenticationHelper.Register(session.Scene, request.Username, request.Password, "用户注册"); - Log.Debug($"Register 当前的服务器是:{session.Scene.SceneConfigId}"); - } -} \ No newline at end of file diff --git a/Hotfix/Outer/Authentication/System/AccountSystem.cs b/Hotfix/Outer/Authentication/System/AccountSystem.cs index 6696f3c..983e9ed 100644 --- a/Hotfix/Outer/Authentication/System/AccountSystem.cs +++ b/Hotfix/Outer/Authentication/System/AccountSystem.cs @@ -1,7 +1,7 @@ using Fantasy; using Fantasy.Entitas.Interface; -namespace Fantasy.Authentication; +namespace NB.Authentication; public class AccountDestroySystem : DestroySystem { diff --git a/Hotfix/Outer/Authentication/System/AuthenticationComponentSystem.cs b/Hotfix/Outer/Authentication/System/AuthenticationComponentSystem.cs index e29417e..83b6124 100644 --- a/Hotfix/Outer/Authentication/System/AuthenticationComponentSystem.cs +++ b/Hotfix/Outer/Authentication/System/AuthenticationComponentSystem.cs @@ -9,7 +9,7 @@ using Fantasy.Platform.Net; #pragma warning disable CS8602 // Dereference of a possibly null reference. #pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type. -namespace Fantasy.Authentication; +namespace NB.Authentication; public sealed class AuthenticationComponentDestroySystem : DestroySystem { @@ -19,7 +19,7 @@ public sealed class AuthenticationComponentDestroySystem : DestroySystem Login(this AuthenticationComponent self, string userName, string password) + + internal static async FTask<(uint ErrorCode, long AccountId)> Login(this AuthenticationComponent self, + string userName, string password) { // 1、检查传递的参数是否完整 - if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password)) { - // 这个1代表的是参数不完整。 - return (1, 0); + return (ErrorCode.ErrArgs, 0); } - - // 检查账号是否应该在当前鉴权服务器中处理 + // 检查账号是否应该在当前鉴权服务器中处理 var position = HashCodeHelper.MurmurHash3(userName) % self.AuthenticationCount; if (self.Position != position) { // 这个3代表的是当前账号不应该在这个鉴权服务器处理。 - return (3, 0); + // return (3, 0); + return (ErrorCode.ErrServer, 0); } var scene = self.Scene; - var worldDateBase = scene.World.DataBase;//DateBase + var worldDateBase = scene.World.DataBase; //DateBase var usernameHashCode = userName.GetHashCode(); - - using (var @lock = await scene.CoroutineLockComponent.Wait((int)LockType.AuthenticationLoginLock, usernameHashCode)) + + using (var @lock = + await scene.CoroutineLockComponent.Wait((int)LockType.AuthenticationLoginLock, usernameHashCode)) { // 如果用户频繁发生登录的请求,导致服务器会频繁请求数据库或缓存。 // 针对这个问题咱们可以利用缓存来解决这个问题。 @@ -71,13 +71,13 @@ internal static class AuthenticationComponentSystem // 2、key:userName + password, Value = ? // 3、为了防止缓存暴涨、肯定需要一个定期清理的过程,Value肯定是要一个实体了。 // 4、因为这个实体下面咱们可以挂载一个组件,这个组件的作用就是定时清理这个缓存。5 - + // 问题 // 1、如果用户的密码改了怎么办? // 因为缓存中有定时清除的,所以遇到改密码的情况下,最多等待这个缓存清除了,然后就可以登录了。 // 2、如果我不这样做,还有什么其他办法? // 通过防火墙的策略来限制用户请求,比如100ms请求一次。 - + // 作业: // 在这个AccountCacheInfo下创建一个组件,这个组件的功能就是定时清理这个缓存。 @@ -87,23 +87,29 @@ internal static class AuthenticationComponentSystem if (self.LoginAccounts.TryGetValue(loginAccountsKey, out var accountCacheInfo)) { account = accountCacheInfo.GetComponent(); - + if (account == null) { - return (2, 0); + return (ErrorCode.ErrAccountOrPass, 0); } - return (0, account.Id); + return (ErrorCode.Successful, account.Id); } uint result = 0; accountCacheInfo = Entity.Create(scene, true, true); - account = await worldDateBase.First(d => d.Username == userName && d.Password == password); + account = await worldDateBase.First(d => d.Username == userName); if (account == null) { - // 这个2代表的是该用户没有注册或者用户或密码错误 - result = 2; + // 没有注册 + return (ErrorCode.ErrAccountOrPass, -1); //返回-1,用于判断是否需要自动注册 + } + + if (account.Password != password) + { + //密码错误 + result = ErrorCode.ErrAccountOrPass; } else { @@ -123,7 +129,7 @@ internal static class AuthenticationComponentSystem return (result, 0); } - return (0, account.Id); + return (ErrorCode.Successful, account.Id); } } @@ -134,46 +140,48 @@ internal static class AuthenticationComponentSystem /// /// /// - internal static async FTask Register(this AuthenticationComponent self, string username, string password, string source) + internal static async FTask Register(this AuthenticationComponent self, string username, string password, + string source) { // 1、检查传递的参数是否完整 - + if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password)) { // 这个1代表的是参数不完整。 - return 1; + return ErrorCode.ErrArgs; } - + // 检查账号是否应该在当前鉴权服务器中处理 var position = HashCodeHelper.MurmurHash3(username) % self.AuthenticationCount; if (self.Position != position) { - // 这个3代表的是当前账号不应该在这个鉴权服务器处理。 - return 3; + // 这个代表的是当前账号不应该在这个鉴权服务器处理。 + return ErrorCode.ErrServer; } var usernameHashCode = username.GetHashCode(); var scene = self.Scene; - + // 利用协程锁来解决异步的原子问题 - using (var @lock = await scene.CoroutineLockComponent.Wait((int)LockType.AuthenticationRegisterLock, usernameHashCode)) + using (var @lock = + await scene.CoroutineLockComponent.Wait((int)LockType.AuthenticationRegisterLock, usernameHashCode)) { // 利用缓存来减少频繁请求数据库或缓存的压力。 - + if (self.Accounts.TryGetValue(username, out var account)) { // 这个2代表的是该用户已经存在。 - return 2; + return ErrorCode.ErrAccountHave; } - + // 2、数据库查询该账号是否存在 var worldDateBase = scene.World.DataBase; var isExist = await worldDateBase.Exist(d => d.Username == username); if (isExist) { // 这个2代表的是该用户已经存在。 - return 2; + return ErrorCode.ErrAccountHave; } //3、执行到这里的话,表示数据库或缓存没有该账号的注册信息,需要咱们创建一个。 @@ -190,7 +198,7 @@ internal static class AuthenticationComponentSystem account.AddComponent().TimeOut(4000); // 这个0代表的是操作成功 Log.Info($"Register source:{source} username:{username} accountId:{accountId}"); - return 0; + return ErrorCode.Successful; } } @@ -213,7 +221,7 @@ internal static class AuthenticationComponentSystem { return; } - + Log.Debug($"Remove cache username:{username} Count:{self.Accounts.Count}"); if (isDispose) @@ -225,9 +233,9 @@ internal static class AuthenticationComponentSystem internal static async FTask Remove(this AuthenticationComponent self, long accountId, string source) { var scene = self.Scene; - + // 其实呢,这里没必要加协程锁,这里加是为了给大家加深下这个协程锁的印象。 - + using (var @lock = await scene.CoroutineLockComponent.Wait((int)LockType.AuthenticationRemoveLock, accountId)) { var worldDateBase = scene.World.DataBase; diff --git a/Hotfix/Outer/Authentication/System/AuthenticationHelper.cs b/Hotfix/Outer/Authentication/System/AuthenticationHelper.cs index fe178a4..b319b86 100644 --- a/Hotfix/Outer/Authentication/System/AuthenticationHelper.cs +++ b/Hotfix/Outer/Authentication/System/AuthenticationHelper.cs @@ -1,7 +1,7 @@ using Fantasy; using Fantasy.Async; -namespace Fantasy.Authentication; +namespace NB.Authentication; public static class AuthenticationHelper { diff --git a/Hotfix/Outer/Authentication/System/Jwt/AuthenticationJwtComponentSystem.cs b/Hotfix/Outer/Authentication/System/Jwt/AuthenticationJwtComponentSystem.cs index 7b5cd06..cd3bf77 100644 --- a/Hotfix/Outer/Authentication/System/Jwt/AuthenticationJwtComponentSystem.cs +++ b/Hotfix/Outer/Authentication/System/Jwt/AuthenticationJwtComponentSystem.cs @@ -4,7 +4,7 @@ using Fantasy; using Fantasy.Entitas.Interface; using Microsoft.IdentityModel.Tokens; -namespace Fantasy.Authentication.Jwt; +namespace NB.Authentication.Jwt; public sealed class AuthenticationJwtComponentAwakeSystem : AwakeSystem { diff --git a/Hotfix/Outer/Authentication/System/Jwt/AuthenticationJwtHelper.cs b/Hotfix/Outer/Authentication/System/Jwt/AuthenticationJwtHelper.cs index 48fa320..1ed5bf5 100644 --- a/Hotfix/Outer/Authentication/System/Jwt/AuthenticationJwtHelper.cs +++ b/Hotfix/Outer/Authentication/System/Jwt/AuthenticationJwtHelper.cs @@ -1,6 +1,6 @@ using Fantasy; -namespace Fantasy.Authentication.Jwt; +namespace NB.Authentication.Jwt; public static class AuthenticationJwtHelper { diff --git a/Hotfix/Outer/Authentication/System/TimeOut/AccountCacheInfoTimeOutSystem.cs b/Hotfix/Outer/Authentication/System/TimeOut/AccountCacheInfoTimeOutSystem.cs index a81849b..eb1bd78 100644 --- a/Hotfix/Outer/Authentication/System/TimeOut/AccountCacheInfoTimeOutSystem.cs +++ b/Hotfix/Outer/Authentication/System/TimeOut/AccountCacheInfoTimeOutSystem.cs @@ -2,7 +2,7 @@ using Fantasy; using Fantasy.Entitas.Interface; // ReSharper disable ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract -namespace Fantasy.Authentication; +namespace NB.Authentication; public sealed class AccountCacheInfoTimeOutDestroySystem : DestroySystem { diff --git a/Hotfix/Outer/Authentication/System/TimeOut/AccountTimeOutSystem.cs b/Hotfix/Outer/Authentication/System/TimeOut/AccountTimeOutSystem.cs index 8906e62..58601aa 100644 --- a/Hotfix/Outer/Authentication/System/TimeOut/AccountTimeOutSystem.cs +++ b/Hotfix/Outer/Authentication/System/TimeOut/AccountTimeOutSystem.cs @@ -1,7 +1,7 @@ using Fantasy; using Fantasy.Entitas.Interface; -namespace Fantasy.Authentication; +namespace NB.Authentication; public sealed class AccountTimeOutDestroySystem : DestroySystem { diff --git a/Hotfix/Outer/Game/Handler/ItemFactory.cs b/Hotfix/Outer/Game/Handler/ItemFactory.cs new file mode 100644 index 0000000..1f54bb0 --- /dev/null +++ b/Hotfix/Outer/Game/Handler/ItemFactory.cs @@ -0,0 +1,6 @@ +namespace NB.Game; + +public class ItemFactory +{ + +} \ No newline at end of file diff --git a/Hotfix/Outer/Game/System/ItemManagerComponentSystem.cs b/Hotfix/Outer/Game/System/ItemManagerComponentSystem.cs new file mode 100644 index 0000000..feb7270 --- /dev/null +++ b/Hotfix/Outer/Game/System/ItemManagerComponentSystem.cs @@ -0,0 +1,6 @@ +namespace NB.Game.System; + +public class ItemManagerComponentSystem +{ + +} \ No newline at end of file diff --git a/Hotfix/Outer/Gate/Handler/Outer/C2G_GetAccountInfoRequestHandler.cs b/Hotfix/Outer/Gate/Handler/Outer/C2G_GetAccountInfoRequestHandler.cs index 96e9cda..62036d6 100644 --- a/Hotfix/Outer/Gate/Handler/Outer/C2G_GetAccountInfoRequestHandler.cs +++ b/Hotfix/Outer/Gate/Handler/Outer/C2G_GetAccountInfoRequestHandler.cs @@ -1,10 +1,9 @@ using Fantasy; using Fantasy.Async; -using Fantasy.Gate; using Fantasy.Network; using Fantasy.Network.Interface; -namespace System.Gate; +namespace NB.Gate; public sealed class C2G_GetAccountInfoRequestHandler : MessageRPC { diff --git a/Hotfix/Outer/Gate/Handler/Outer/C2G_LoginRequestHandler.cs b/Hotfix/Outer/Gate/Handler/Outer/C2G_LoginRequestHandler.cs index a6b27cd..a6fb7a4 100644 --- a/Hotfix/Outer/Gate/Handler/Outer/C2G_LoginRequestHandler.cs +++ b/Hotfix/Outer/Gate/Handler/Outer/C2G_LoginRequestHandler.cs @@ -1,13 +1,12 @@ -using System.Gate.System; +using NB.Gate.System; using Fantasy; using Fantasy.Async; -using Fantasy.Gate; using Fantasy.Network; using Fantasy.Network.Interface; #pragma warning disable CS8604 // Possible null reference argument. -namespace System.Gate.Handler; +namespace NB.Gate.Handler; public sealed class C2G_LoginRequestHandler : MessageRPC { diff --git a/Hotfix/Outer/Gate/System/GameAccount/GameAccountFactory.cs b/Hotfix/Outer/Gate/System/GameAccount/GameAccountFactory.cs index e48ddd0..03a6b3b 100644 --- a/Hotfix/Outer/Gate/System/GameAccount/GameAccountFactory.cs +++ b/Hotfix/Outer/Gate/System/GameAccount/GameAccountFactory.cs @@ -1,10 +1,9 @@ using Fantasy; using Fantasy.Async; using Fantasy.Entitas; -using Fantasy.Gate; using Fantasy.Helper; -namespace System.Gate; +namespace NB.Gate; public static class GameAccountFactory { diff --git a/Hotfix/Outer/Gate/System/GameAccount/GameAccountFlagComponentSystem.cs b/Hotfix/Outer/Gate/System/GameAccount/GameAccountFlagComponentSystem.cs index ec9b7cb..1ce520c 100644 --- a/Hotfix/Outer/Gate/System/GameAccount/GameAccountFlagComponentSystem.cs +++ b/Hotfix/Outer/Gate/System/GameAccount/GameAccountFlagComponentSystem.cs @@ -1,7 +1,6 @@ using Fantasy.Entitas.Interface; -using Fantasy.Gate; -namespace System.Gate; +namespace NB.Gate; public sealed class GameAccountFlagComponentDestroySystem : DestroySystem { diff --git a/Hotfix/Outer/Gate/System/GameAccount/GameAccountHelper.cs b/Hotfix/Outer/Gate/System/GameAccount/GameAccountHelper.cs index 59b92c7..d3d542c 100644 --- a/Hotfix/Outer/Gate/System/GameAccount/GameAccountHelper.cs +++ b/Hotfix/Outer/Gate/System/GameAccount/GameAccountHelper.cs @@ -1,10 +1,9 @@ -using System.Gate.System; +using NB.Gate.System; using Fantasy; using Fantasy.Async; -using Fantasy.Gate; using Fantasy.Network; -namespace System.Gate; +namespace NB.Gate; public static class GameAccountHelper { diff --git a/Hotfix/Outer/Gate/System/GameAccount/GameAccountSystem.cs b/Hotfix/Outer/Gate/System/GameAccount/GameAccountSystem.cs index fcb11e2..66135c0 100644 --- a/Hotfix/Outer/Gate/System/GameAccount/GameAccountSystem.cs +++ b/Hotfix/Outer/Gate/System/GameAccount/GameAccountSystem.cs @@ -1,7 +1,6 @@ using Fantasy.Entitas.Interface; -using Fantasy.Gate; -namespace System.Gate; +namespace NB.Gate; public sealed class GameAccountDestroySystem : DestroySystem { diff --git a/Hotfix/Outer/Gate/System/GameAccountManageComponentSystem.cs b/Hotfix/Outer/Gate/System/GameAccountManageComponentSystem.cs index 7db5d6b..6adcf33 100644 --- a/Hotfix/Outer/Gate/System/GameAccountManageComponentSystem.cs +++ b/Hotfix/Outer/Gate/System/GameAccountManageComponentSystem.cs @@ -1,7 +1,6 @@ using Fantasy.Entitas.Interface; -using Fantasy.Gate; -namespace System.Gate.System; +namespace NB.Gate.System; public sealed class GameAccountManageComponentDestroySystem : DestroySystem { diff --git a/Hotfix/Outer/Gate/System/JWT/GateJWTComponentSystem.cs b/Hotfix/Outer/Gate/System/JWT/GateJWTComponentSystem.cs index d3f9887..720052b 100644 --- a/Hotfix/Outer/Gate/System/JWT/GateJWTComponentSystem.cs +++ b/Hotfix/Outer/Gate/System/JWT/GateJWTComponentSystem.cs @@ -1,11 +1,10 @@ using System.IdentityModel.Tokens.Jwt; using System.Security.Cryptography; using Fantasy.Entitas.Interface; -using Fantasy.Gate; using Microsoft.IdentityModel.Tokens; #pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type. -namespace System.Gate; +namespace NB.Gate; public sealed class GateJWTComponentAwakeSystem : AwakeSystem { diff --git a/Hotfix/Outer/Gate/System/JWT/GateJWTHelper.cs b/Hotfix/Outer/Gate/System/JWT/GateJWTHelper.cs index 2e3deff..238a393 100644 --- a/Hotfix/Outer/Gate/System/JWT/GateJWTHelper.cs +++ b/Hotfix/Outer/Gate/System/JWT/GateJWTHelper.cs @@ -1,8 +1,7 @@ using System.IdentityModel.Tokens.Jwt; using Fantasy; -using Fantasy.Gate; -namespace System.Gate; +namespace NB.Gate; public static class GateJWTHelper { diff --git a/Main/Program.cs b/Main/Program.cs index bed81e3..846282c 100644 --- a/Main/Program.cs +++ b/Main/Program.cs @@ -26,4 +26,4 @@ SceneConfigData.Initialize(sceneConfigText); // 这里用的是NLog日志系统注册到框架中。 Log.Register(new Fantasy.NLog("Server")); -await Entry.Start(AssemblyHelper.Assemblies); +await Entry.Start(NB.AssemblyHelper.Assemblies);