客户端玩家下线的时候通知gate网关 gateHelper函数通过offline下线函数 通知 各个服务器

This commit is contained in:
SnowShow 2025-04-02 17:14:05 +08:00
parent 47894751e0
commit 79e190c58b
54 changed files with 312 additions and 35 deletions

View File

@ -0,0 +1,10 @@
2025-04-02 16:59:26.8261 (OnCreateScene_InitEvent.cs:16) 初始化鉴权服务器组件
2025-04-02 16:59:27.2194 (OnCreateScene_InitEvent.cs:16) 初始化鉴权服务器组件
2025-04-02 16:59:27.6185 (OnCreateScene_InitEvent.cs:21) 初始网关Gate服务器组件
2025-04-02 16:59:28.0036 (OnCreateScene_InitEvent.cs:21) 初始网关Gate服务器组件
2025-04-02 16:59:50.0545 (AuthenticationComponentSystem.cs:130) Authentication: Login Success(登录成功),username:wangwei,password:123,source:客户端,Position:1001
2025-04-02 16:59:50.2974 (C2G_LoginRequestHandler.cs:31) Gate校验登录成功用户116299279127281665
2025-04-02 16:59:50.3233 (GameAccountManageComponentSystem.cs:102) Gate 当前缓存中的 SessionID 2589055308819070976
2025-04-02 16:59:50.3233 (C2G_LoginRequestHandler.cs:43) Gate : Login 登录成功GameAccount:session2589055308819070976 AccountId:116299279127281665
2025-04-02 16:59:50.3575 (G2C_GetGameAccountInfoHandler.cs:37) Gate: 获取账号信息 AccountId SnowShow
2025-04-02 16:59:56.0574 (AuthenticationComponentSystem.cs:150) Authentication:Login:username:wangwei 用户移除成功 从缓存中

View File

@ -0,0 +1,18 @@
2025-04-02 16:56:15.4982 System.ArgumentException: An item with the same key has already been added. Key: Fantasy.G2Chat_LoginRequest
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Fantasy.Network.Interface.MessageDispatcherComponent.LoadInner(Int64 assemblyIdentity)
at Fantasy.Network.Interface.MessageDispatcherComponent.<>c__DisplayClass16_0.<Load>b__0()
at Fantasy.ThreadSynchronizationContext.Update()
2025-04-02 16:56:33.3541 System.ArgumentException: An item with the same key has already been added. Key: Fantasy.G2Chat_LoginRequest
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Fantasy.Network.Interface.MessageDispatcherComponent.LoadInner(Int64 assemblyIdentity)
at Fantasy.Network.Interface.MessageDispatcherComponent.<>c__DisplayClass16_0.<Load>b__0()
at Fantasy.ThreadSynchronizationContext.Update()
2025-04-02 16:57:58.0473 System.ArgumentException: An item with the same key has already been added. Key: Fantasy.G2Chat_LoginRequest
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Fantasy.Network.Interface.MessageDispatcherComponent.LoadInner(Int64 assemblyIdentity)
at Fantasy.Network.Interface.MessageDispatcherComponent.<>c__DisplayClass16_0.<Load>b__0()
at Fantasy.ThreadSynchronizationContext.Update()

View File

@ -0,0 +1,18 @@
2025-04-02 16:56:15.4342 初始化序列化器成功数量为2
2025-04-02 16:56:33.3030 初始化序列化器成功数量为2
2025-04-02 16:57:57.9899 初始化序列化器成功数量为2
2025-04-02 16:59:26.0246 初始化序列化器成功数量为2
2025-04-02 16:59:26.5981 SceneConfigId = 1001 networkTarget = Inner TCPServer Listen 127.0.0.1:11001
2025-04-02 16:59:26.8136 SceneConfigId = 1001 networkTarget = Outer KCPServer Listen 127.0.0.1:21001
2025-04-02 16:59:26.8261 (AuthenticationJWTComponentSystem.cs:44) RSA密钥导入成功
2025-04-02 16:59:27.0291 SceneConfigId = 1002 networkTarget = Inner TCPServer Listen 127.0.0.1:11002
2025-04-02 16:59:27.2194 SceneConfigId = 1002 networkTarget = Outer KCPServer Listen 127.0.0.1:21002
2025-04-02 16:59:27.2194 (AuthenticationJWTComponentSystem.cs:44) RSA密钥导入成功
2025-04-02 16:59:27.4309 SceneConfigId = 1010 networkTarget = Inner TCPServer Listen 127.0.0.1:11010
2025-04-02 16:59:27.6160 SceneConfigId = 1010 networkTarget = Outer KCPServer Listen 127.0.0.1:21010
2025-04-02 16:59:27.8212 SceneConfigId = 1011 networkTarget = Inner TCPServer Listen 127.0.0.1:11011
2025-04-02 16:59:28.0036 SceneConfigId = 1011 networkTarget = Outer KCPServer Listen 127.0.0.1:21011
2025-04-02 16:59:28.2123 SceneConfigId = 1026 networkTarget = Inner TCPServer Listen 127.0.0.1:11026
2025-04-02 16:59:28.4153 SceneConfigId = 1026 networkTarget = Outer TCPServer Listen 127.0.0.1:21016
2025-04-02 16:59:28.4153 Process:1 Startup Complete SceneCount:5
2025-04-02 16:59:50.3361 (G2Chat_LoginRequestHandler.cs:19) 登录聊天服务器成功 SnowShow AccountId 116299279127281665 GateRoutedId 2589055308819070976

View File

@ -0,0 +1 @@
2025-04-02 16:59:50.2974 (GateJWTComponentSystem.cs:47) Gate:Token签名校验成功

View File

@ -0,0 +1,36 @@
2025-04-02 17:01:45.9357 (OnCreateScene_InitEvent.cs:16) 初始化鉴权服务器组件
2025-04-02 17:01:46.3516 (OnCreateScene_InitEvent.cs:16) 初始化鉴权服务器组件
2025-04-02 17:01:46.7610 (OnCreateScene_InitEvent.cs:21) 初始网关Gate服务器组件
2025-04-02 17:01:47.1682 (OnCreateScene_InitEvent.cs:21) 初始网关Gate服务器组件
2025-04-02 17:01:53.9070 (AuthenticationComponentSystem.cs:130) Authentication: Login Success(登录成功),username:wangwei,password:123,source:客户端,Position:1001
2025-04-02 17:01:54.1413 (C2G_LoginRequestHandler.cs:31) Gate校验登录成功用户116299279127281665
2025-04-02 17:01:54.1677 (GameAccountManageComponentSystem.cs:102) Gate 当前缓存中的 SessionID 2589022323470237696
2025-04-02 17:01:54.1677 (C2G_LoginRequestHandler.cs:43) Gate : Login 登录成功GameAccount:session2589022323470237696 AccountId:116299279127281665
2025-04-02 17:01:54.2161 (G2C_GetGameAccountInfoHandler.cs:37) Gate: 获取账号信息 AccountId SnowShow
2025-04-02 17:01:59.9082 (AuthenticationComponentSystem.cs:150) Authentication:Login:username:wangwei 用户移除成功 从缓存中
2025-04-02 17:07:26.4240 (OnCreateScene_InitEvent.cs:16) 初始化鉴权服务器组件
2025-04-02 17:07:26.8215 (OnCreateScene_InitEvent.cs:16) 初始化鉴权服务器组件
2025-04-02 17:07:27.2296 (OnCreateScene_InitEvent.cs:21) 初始网关Gate服务器组件
2025-04-02 17:07:27.6696 (OnCreateScene_InitEvent.cs:21) 初始网关Gate服务器组件
2025-04-02 17:08:09.7733 (AuthenticationComponentSystem.cs:130) Authentication: Login Success(登录成功),username:wangwei,password:123,source:客户端,Position:1001
2025-04-02 17:08:10.0083 (C2G_LoginRequestHandler.cs:31) Gate校验登录成功用户116299279127281665
2025-04-02 17:08:10.0360 (GameAccountManageComponentSystem.cs:102) Gate 当前缓存中的 SessionID 2589099289284182016
2025-04-02 17:08:10.0360 (C2G_LoginRequestHandler.cs:43) Gate : Login 登录成功GameAccount:session2589099289284182016 AccountId:116299279127281665
2025-04-02 17:08:10.0743 (G2C_GetGameAccountInfoHandler.cs:37) Gate: 获取账号信息 AccountId SnowShow
2025-04-02 17:08:15.7752 (AuthenticationComponentSystem.cs:150) Authentication:Login:username:wangwei 用户移除成功 从缓存中
2025-04-02 17:09:14.9881 (GameAccountSystem.cs:29) Gate gameAccount 下线前 保存数据到 数据库中
2025-04-02 17:11:49.9873 (OnCreateScene_InitEvent.cs:16) 初始化鉴权服务器组件
2025-04-02 17:11:50.4176 (OnCreateScene_InitEvent.cs:16) 初始化鉴权服务器组件
2025-04-02 17:11:50.8359 (OnCreateScene_InitEvent.cs:21) 初始网关Gate服务器组件
2025-04-02 17:11:51.2496 (OnCreateScene_InitEvent.cs:21) 初始网关Gate服务器组件
2025-04-02 17:12:24.3154 (AuthenticationComponentSystem.cs:130) Authentication: Login Success(登录成功),username:wangwei,password:123,source:客户端,Position:1001
2025-04-02 17:12:24.5750 (C2G_LoginRequestHandler.cs:31) Gate校验登录成功用户116299279127281665
2025-04-02 17:12:24.6011 (GameAccountManageComponentSystem.cs:102) Gate 当前缓存中的 SessionID 2589079498074882048
2025-04-02 17:12:24.6011 (C2G_LoginRequestHandler.cs:43) Gate : Login 登录成功GameAccount:session2589079498074882048 AccountId:116299279127281665
2025-04-02 17:12:24.6390 (G2C_GetGameAccountInfoHandler.cs:37) Gate: 获取账号信息 AccountId SnowShow
2025-04-02 17:12:30.3167 (AuthenticationComponentSystem.cs:150) Authentication:Login:username:wangwei 用户移除成功 从缓存中
2025-04-02 17:12:54.5523 (GameAccountSystem.cs:29) Gate gameAccount 下线前 保存数据到 数据库中
2025-04-02 17:12:54.6171 (G2Chat_OfflineRequestHandler.cs:11) chat 聊天服务器SnowShow 下线
2025-04-02 17:12:54.6171 (GateLoginHelper.cs:44) Gate chat聊天服务器下线成功
2025-04-02 17:12:54.6171 (GameAccountSystem.cs:29) Gate gameAccount 下线前 保存数据到 数据库中
2025-04-02 17:12:54.6171 (EntityTimeOutComponentSystem.cs:52) session : 0 Dispose

View File

@ -0,0 +1,31 @@
2025-04-02 17:09:15.0026 Fantasy.Timer.TimerComponent Update Error MongoDB.Bson.BsonSerializationException: An error occurred while serializing the Routes field of class Fantasy.GameAccount: When using DictionaryRepresentation.Document key values must serialize as strings.
---> MongoDB.Bson.BsonSerializationException: When using DictionaryRepresentation.Document key values must serialize as strings.
at MongoDB.Bson.Serialization.Serializers.DictionarySerializerBase`3.SerializeKeyString(TKey key)
at MongoDB.Bson.Serialization.Serializers.DictionarySerializerBase`3.SerializeDocumentRepresentation(BsonSerializationContext context, TDictionary value)
at MongoDB.Bson.Serialization.Serializers.DictionarySerializerBase`3.SerializeValue(BsonSerializationContext context, BsonSerializationArgs args, TDictionary value)
at MongoDB.Bson.Serialization.Serializers.ClassSerializerBase`1.Serialize(BsonSerializationContext context, BsonSerializationArgs args, TValue value)
at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Serialize(IBsonSerializer serializer, BsonSerializationContext context, Object value)
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.SerializeNormalMember(BsonSerializationContext context, Object obj, BsonMemberMap memberMap)
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.SerializeMember(BsonSerializationContext context, Object obj, BsonMemberMap memberMap)
--- End of inner exception stack trace ---
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.SerializeMember(BsonSerializationContext context, Object obj, BsonMemberMap memberMap)
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.SerializeClass(BsonSerializationContext context, BsonSerializationArgs args, TClass document)
at MongoDB.Bson.Serialization.BsonClassMapSerializer`1.Serialize(BsonSerializationContext context, BsonSerializationArgs args, TClass value)
at MongoDB.Bson.BsonExtensionMethods.ToBson(Object obj, Type nominalType, BsonBinaryWriterSettings writerSettings, IBsonSerializer serializer, Action`1 configurator, BsonSerializationArgs args, Int32 estimatedBsonSize)
at MongoDB.Bson.BsonExtensionMethods.ToBson[TNominalType](TNominalType obj, IBsonSerializer`1 serializer, BsonBinaryWriterSettings writerSettings, Action`1 configurator, BsonSerializationArgs args, Int32 estimatedBsonSize)
at Fantasy.Serialize.BsonPackHelper.Serialize[T](T object)
at Fantasy.Serialize.BsonPackHelper.Clone[T](T t)
at Fantasy.DataBase.MongoDataBase.Save[T](T entity, String collection)
at Hotfix.GameAccountSystem.SaveToDatabase(GameAccount self, Scene scene) in D:\UnityProject\EintooAR\GameServer\Server\Hotfix\Outter\Gate\GameAccount\GameAccountSystem.cs:line 12
at Hotfix.GameAccountSystem.DisConnect(GameAccount self) in D:\UnityProject\EintooAR\GameServer\Server\Hotfix\Outter\Gate\GameAccount\GameAccountSystem.cs:line 30
at Hotfix.EntityTimeOutComponentSystem.Handler(EntityTimeOutComponent self, Int64 parentRunTimeId, Func`1 callback) in D:\UnityProject\EintooAR\GameServer\Server\Hotfix\Outter\Entity\EntityTimeOutComponentSystem.cs:line 48
at Fantasy.Async.FTask.InnerCoroutine()
at Fantasy.Async.FTask.InnerCoroutine()
at Hotfix.EntityTimeOutComponentSystem.<>c__DisplayClass2_0.<TimeOut>b__0() in D:\UnityProject\EintooAR\GameServer\Server\Hotfix\Outter\Entity\EntityTimeOutComponentSystem.cs:line 35
at Fantasy.Timer.TimerSchedulerNet.Update()
at Fantasy.Entitas.EntityComponent.Update()
at Fantasy.Entitas.EntityComponent.Update()
at Fantasy.Scene.Update()
at Fantasy.MultiThreadScheduler.Loop(Scene scene, CancellationToken cancellationToken)
at Fantasy.MultiThreadScheduler.<>c__DisplayClass5_0.<Add>b__0()

View File

@ -0,0 +1,45 @@
2025-04-02 17:01:45.0878 初始化序列化器成功数量为2
2025-04-02 17:01:45.7153 SceneConfigId = 1001 networkTarget = Inner TCPServer Listen 127.0.0.1:11001
2025-04-02 17:01:45.9191 SceneConfigId = 1001 networkTarget = Outer KCPServer Listen 127.0.0.1:21001
2025-04-02 17:01:45.9357 (AuthenticationJWTComponentSystem.cs:44) RSA密钥导入成功
2025-04-02 17:01:46.1523 SceneConfigId = 1002 networkTarget = Inner TCPServer Listen 127.0.0.1:11002
2025-04-02 17:01:46.3495 SceneConfigId = 1002 networkTarget = Outer KCPServer Listen 127.0.0.1:21002
2025-04-02 17:01:46.3516 (AuthenticationJWTComponentSystem.cs:44) RSA密钥导入成功
2025-04-02 17:01:46.5734 SceneConfigId = 1010 networkTarget = Inner TCPServer Listen 127.0.0.1:11010
2025-04-02 17:01:46.7610 SceneConfigId = 1010 networkTarget = Outer KCPServer Listen 127.0.0.1:21010
2025-04-02 17:01:46.9788 SceneConfigId = 1011 networkTarget = Inner TCPServer Listen 127.0.0.1:11011
2025-04-02 17:01:47.1682 SceneConfigId = 1011 networkTarget = Outer KCPServer Listen 127.0.0.1:21011
2025-04-02 17:01:47.3781 SceneConfigId = 1026 networkTarget = Inner TCPServer Listen 127.0.0.1:11026
2025-04-02 17:01:47.5875 SceneConfigId = 1026 networkTarget = Outer TCPServer Listen 127.0.0.1:21016
2025-04-02 17:01:47.5875 Process:1 Startup Complete SceneCount:5
2025-04-02 17:01:54.1801 (G2Chat_LoginRequestHandler.cs:19) 登录聊天服务器成功 SnowShow AccountId 116299279127281665 GateRoutedId 2589022323470237696
2025-04-02 17:07:25.4986 初始化序列化器成功数量为2
2025-04-02 17:07:26.1987 SceneConfigId = 1001 networkTarget = Inner TCPServer Listen 127.0.0.1:11001
2025-04-02 17:07:26.4064 SceneConfigId = 1001 networkTarget = Outer KCPServer Listen 127.0.0.1:21001
2025-04-02 17:07:26.4240 (AuthenticationJWTComponentSystem.cs:44) RSA密钥导入成功
2025-04-02 17:07:26.6285 SceneConfigId = 1002 networkTarget = Inner TCPServer Listen 127.0.0.1:11002
2025-04-02 17:07:26.8215 SceneConfigId = 1002 networkTarget = Outer KCPServer Listen 127.0.0.1:21002
2025-04-02 17:07:26.8215 (AuthenticationJWTComponentSystem.cs:44) RSA密钥导入成功
2025-04-02 17:07:27.0385 SceneConfigId = 1010 networkTarget = Inner TCPServer Listen 127.0.0.1:11010
2025-04-02 17:07:27.2296 SceneConfigId = 1010 networkTarget = Outer KCPServer Listen 127.0.0.1:21010
2025-04-02 17:07:27.4622 SceneConfigId = 1011 networkTarget = Inner TCPServer Listen 127.0.0.1:11011
2025-04-02 17:07:27.6696 SceneConfigId = 1011 networkTarget = Outer KCPServer Listen 127.0.0.1:21011
2025-04-02 17:07:27.8931 SceneConfigId = 1026 networkTarget = Inner TCPServer Listen 127.0.0.1:11026
2025-04-02 17:07:28.1026 SceneConfigId = 1026 networkTarget = Outer TCPServer Listen 127.0.0.1:21016
2025-04-02 17:07:28.1026 Process:1 Startup Complete SceneCount:5
2025-04-02 17:08:10.0492 (G2Chat_LoginRequestHandler.cs:19) 登录聊天服务器成功 SnowShow AccountId 116299279127281665 GateRoutedId 2589099289284182016
2025-04-02 17:11:49.1038 初始化序列化器成功数量为2
2025-04-02 17:11:49.7598 SceneConfigId = 1001 networkTarget = Inner TCPServer Listen 127.0.0.1:11001
2025-04-02 17:11:49.9717 SceneConfigId = 1001 networkTarget = Outer KCPServer Listen 127.0.0.1:21001
2025-04-02 17:11:49.9873 (AuthenticationJWTComponentSystem.cs:44) RSA密钥导入成功
2025-04-02 17:11:50.2054 SceneConfigId = 1002 networkTarget = Inner TCPServer Listen 127.0.0.1:11002
2025-04-02 17:11:50.4176 SceneConfigId = 1002 networkTarget = Outer KCPServer Listen 127.0.0.1:21002
2025-04-02 17:11:50.4176 (AuthenticationJWTComponentSystem.cs:44) RSA密钥导入成功
2025-04-02 17:11:50.6331 SceneConfigId = 1010 networkTarget = Inner TCPServer Listen 127.0.0.1:11010
2025-04-02 17:11:50.8359 SceneConfigId = 1010 networkTarget = Outer KCPServer Listen 127.0.0.1:21010
2025-04-02 17:11:51.0480 SceneConfigId = 1011 networkTarget = Inner TCPServer Listen 127.0.0.1:11011
2025-04-02 17:11:51.2496 SceneConfigId = 1011 networkTarget = Outer KCPServer Listen 127.0.0.1:21011
2025-04-02 17:11:51.4815 SceneConfigId = 1026 networkTarget = Inner TCPServer Listen 127.0.0.1:11026
2025-04-02 17:11:51.7176 SceneConfigId = 1026 networkTarget = Outer TCPServer Listen 127.0.0.1:21016
2025-04-02 17:11:51.7176 Process:1 Startup Complete SceneCount:5
2025-04-02 17:12:24.6011 (G2Chat_LoginRequestHandler.cs:19) 登录聊天服务器成功 SnowShow AccountId 116299279127281665 GateRoutedId 2589079498074882048

View File

@ -0,0 +1,5 @@
2025-04-02 17:01:54.1413 (GateJWTComponentSystem.cs:47) Gate:Token签名校验成功
2025-04-02 17:08:10.0083 (GateJWTComponentSystem.cs:47) Gate:Token签名校验成功
2025-04-02 17:09:04.9839 session timeout id:135640032928333824 timeNow:1743584944983 _session.LastReceiveTime:1743584933918 _timeOut:8000
2025-04-02 17:12:24.5750 (GateJWTComponentSystem.cs:47) Gate:Token签名校验成功
2025-04-02 17:12:44.5477 session timeout id:135644413794975744 timeNow:1743585164547 _session.LastReceiveTime:1743585152426 _timeOut:8000

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,6 +2,7 @@ syntax = "proto3";
package Sining.Message;
//Gate
message G2Chat_LoginRequest // IRouteRequest,Chat2G_LoginResponse
{
string GameName = 1;
@ -10,9 +11,25 @@ message G2Chat_LoginRequest // IRouteRequest,Chat2G_LoginResponse
}
message Chat2G_LoginResponse // IRouteResponse
{
int64 ChatUnitRunId = 1 ;
int64 ChatRouteId = 1 ;
}
message G2Chat_OfflineRequest // IRouteRequest, Chat2G_OfflineResponse
{
}
message Chat2G_OfflineResponse // IRouteResponse
{
}
message G2A_TestMessage // IRouteMessage
{
string Tag = 1;

View File

@ -9,6 +9,7 @@ package Fantasy.Network.Message;
// :// Protocol ProtoBuf // Protocol MemoryPack
//Authentication
message C2A_RegisterRequest // IRequest,A2C_RegisterResponse
{
string Username = 1;
@ -32,6 +33,8 @@ message A2C_LoginResponse // IResponse
string Token = 1;
}
//Gate
message C2G_LoginRequest // IRequest,G2C_LoginResponse
{
string Token = 1;
@ -72,8 +75,6 @@ message G2C_OpenGameNameInputWindowsMessage //IMessage
}
message C2G_UpdateAndSaveGameNameRequest //IRequest,G2C_UpdateAndSaveGameNameResponse
{
int64 AccountId = 1 ;
@ -101,6 +102,10 @@ message Chat2C_TestResponse // ICustomRouteResponse
message C2G_TestMessage // IMessage
{
string Tag = 1;

View File

@ -53,18 +53,53 @@ namespace Fantasy
public override void Dispose()
{
ErrorCode = default;
ChatUnitRunId = default;
ChatRouteId = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Chat2G_LoginResponse>(this);
#endif
}
public uint OpCode() { return InnerOpcode.Chat2G_LoginResponse; }
[ProtoMember(1)]
public long ChatUnitRunId { get; set; }
public long ChatRouteId { get; set; }
[ProtoMember(2)]
public uint ErrorCode { get; set; }
}
[ProtoContract]
public partial class G2Chat_OfflineRequest : AMessage, IRouteRequest, IProto
{
public static G2Chat_OfflineRequest Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<G2Chat_OfflineRequest>();
}
public override void Dispose()
{
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<G2Chat_OfflineRequest>(this);
#endif
}
[ProtoIgnore]
public Chat2G_OfflineResponse ResponseType { get; set; }
public uint OpCode() { return InnerOpcode.G2Chat_OfflineRequest; }
}
[ProtoContract]
public partial class Chat2G_OfflineResponse : AMessage, IRouteResponse, IProto
{
public static Chat2G_OfflineResponse Create(Scene scene)
{
return scene.MessagePoolComponent.Rent<Chat2G_OfflineResponse>();
}
public override void Dispose()
{
ErrorCode = default;
#if FANTASY_NET || FANTASY_UNITY
GetScene().MessagePoolComponent.Return<Chat2G_OfflineResponse>(this);
#endif
}
public uint OpCode() { return InnerOpcode.Chat2G_OfflineResponse; }
[ProtoMember(1)]
public uint ErrorCode { get; set; }
}
[ProtoContract]
public partial class G2A_TestMessage : AMessage, IRouteMessage, IProto
{
public static G2A_TestMessage Create(Scene scene)

View File

@ -4,20 +4,22 @@ namespace Fantasy
{
public const uint G2Chat_LoginRequest = 1073751825;
public const uint Chat2G_LoginResponse = 1207969553;
public const uint G2Chat_OfflineRequest = 1073751826;
public const uint Chat2G_OfflineResponse = 1207969554;
public const uint G2A_TestMessage = 939534097;
public const uint G2A_TestRequest = 1073751826;
public const uint G2A_TestResponse = 1207969554;
public const uint G2M_RequestAddressableId = 1073751827;
public const uint M2G_ResponseAddressableId = 1207969555;
public const uint G2Chat_CreateRouteRequest = 1073751828;
public const uint Chat2G_CreateRouteResponse = 1207969556;
public const uint M2M_SendUnitRequest = 1082140437;
public const uint M2M_SendUnitResponse = 1216358165;
public const uint G2A_TestRequest = 1073751827;
public const uint G2A_TestResponse = 1207969555;
public const uint G2M_RequestAddressableId = 1073751828;
public const uint M2G_ResponseAddressableId = 1207969556;
public const uint G2Chat_CreateRouteRequest = 1073751829;
public const uint Chat2G_CreateRouteResponse = 1207969557;
public const uint M2M_SendUnitRequest = 1082140438;
public const uint M2M_SendUnitResponse = 1216358166;
public const uint G2M_SendAddressableMessage = 1744840465;
public const uint G2M_CreateSubSceneRequest = 1073751830;
public const uint M2G_CreateSubSceneResponse = 1207969558;
public const uint G2M_CreateSubSceneRequest = 1073751831;
public const uint M2G_CreateSubSceneResponse = 1207969559;
public const uint G2SubScene_SentMessage = 939534098;
public const uint G2SubScene_AddressableIdRequest = 1073751831;
public const uint SubScene2G_AddressableIdResponse = 1207969559;
public const uint G2SubScene_AddressableIdRequest = 1073751832;
public const uint SubScene2G_AddressableIdResponse = 1207969560;
}
}

View File

@ -11,4 +11,6 @@ public class GameAccount : Entity
public string GameName;
[BsonIgnore]public long SessionRuntimeId;
[BsonIgnore]public Dictionary<int,long> Routes = new Dictionary<int,long>();
}

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Entity")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f380af99fa15e1e6045b8a02edffb583f97f5687")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+47894751e0724034b829def7a67852359b02d23f")]
[assembly: System.Reflection.AssemblyProductAttribute("Entity")]
[assembly: System.Reflection.AssemblyTitleAttribute("Entity")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
9eb20dcf29f796e9cd950d2d315fa986c1ad3725eb1a0b291dd618e8595a36cd
11080d70ef29f1e0498d40d3859614eca85bbc477cda1e69c0e86154d55d09de

View File

@ -15,7 +15,7 @@ public class G2Chat_LoginRequestHandler : RouteRPC<Scene,G2Chat_LoginRequest,Cha
chatUnit.GameName = request.GameName;
response.ErrorCode = GameErrorCode.Success;
response.ChatUnitRunId = chatUnit.RuntimeId;
response.ChatRouteId = chatUnit.RuntimeId;
Log.Info($"登录聊天服务器成功 {request.GameName} AccountId {request.AccountId } GateRoutedId { request.GateRoutedId}");
await FTask.CompletedTask;

View File

@ -0,0 +1,17 @@
using Fantasy;
using Fantasy.Async;
using Fantasy.Network.Interface;
namespace Hotfix;
public class G2Chat_OfflineRequestHandler : RouteRPC<ChatUnit,G2Chat_OfflineRequest,Chat2G_OfflineResponse>
{
protected override async FTask Run(ChatUnit chatUnit, G2Chat_OfflineRequest request, Chat2G_OfflineResponse response, Action reply)
{
Log.Debug($"chat 聊天服务器{chatUnit.GameName} 下线");
chatUnit.Dispose();
response.ErrorCode = GameErrorCode.Success;
await FTask.CompletedTask;
}
}

View File

@ -9,7 +9,7 @@ public class GameAccountFlagComponentDestroySystem : DestroySystem<GameAccountFl
{
if (self.AccountId != 0)
{
GateComponentHelper.Disconnect(self.Scene,self.AccountId,1000* 60 * 5).Coroutine();
GateComponentHelper.Disconnect(self.Scene,self.AccountId,1000 * 10).Coroutine();
self.AccountId = 0;
}
self.Account = null;

View File

@ -31,8 +31,19 @@ public static class GameAccountManageComponentSystem
return self.Accounts.TryGetValue(accountId,out account);
}
public static bool Remove(this GameAccountManageComponent self, long accountId, bool isDispose = true)
public static async FTask<bool> Remove(this GameAccountManageComponent self, long accountId, bool isDispose = true)
{
if (!self.TryGet(accountId, out var account))
{
return false;
}
var errorCode = await GateLoginHelper.Offline(account);
if (errorCode!= GameErrorCode.Success)
{
return false;
}
if (!self.Accounts.Remove(accountId,out var gameAccount))
{
return false;

View File

@ -28,7 +28,7 @@ public static class GameAccountSystem
var accountId = self.Id;
Log.Debug("Gate gameAccount 下线前 保存数据到 数据库中");
await self.SaveToDatabase(scene);
GateComponentHelper.GetGameAccountManageComponent(scene).Remove(accountId);
await GateComponentHelper.GetGameAccountManageComponent(scene).Remove(accountId);
}
}

View File

@ -7,25 +7,49 @@ namespace Hotfix;
public static class GateLoginHelper
{
private static List<Func<Scene, GameAccount, long, FTask<(uint error, long chatUnitId,int routeType)>>> scenes =
private static List<Func<Scene, GameAccount, long, FTask<(uint error, long chatRouteId,int routeType)>>> scenes =
new List<Func<Scene, GameAccount, long, FTask<(uint error, long chatUnitId,int routeType)>>>()
{
OnlineChat
};
public static async FTask Online(Session session, GameAccount account,long gateRouted)
/// <summary>
/// 上线
/// </summary>
/// <param name="session"></param>
/// <param name="account"></param>
/// <param name="gateRouteId"></param>
public static async FTask Online(Session session, GameAccount account,long gateRouteId)
{
foreach (var scene in scenes)
{
var result = await scene(session.Scene, account, gateRouted);
var result = await scene(session.Scene, account, gateRouteId);
if (result.error != GameErrorCode.Success) return;
var routeComponent = session.GetOrAddComponent<RouteComponent>();
routeComponent.AddAddress(result.routeType,result.chatUnitId);
routeComponent.AddAddress(result.routeType,result.chatRouteId);
account.Routes[result.routeType] = result.chatRouteId;
}
//await OnlineChat(session.Scene, account, gateRouted);
}
public static async FTask<(uint error,long chatUnitId,int routeType)> OnlineChat(Scene scene, GameAccount account,long gateRouteId)
public static async FTask<uint> Offline(GameAccount account)
{
var netComponent = account.Scene.NetworkMessagingComponent;
foreach (var (routeType,routeId) in account.Routes)
{
switch (routeType)
{
case RouteType.ChatRoute:
var response = await netComponent.CallInnerRoute(routeId, new G2Chat_OfflineRequest());
if (response.ErrorCode != GameErrorCode.Success) return response.ErrorCode;
Log.Debug($"Gate chat聊天服务器下线成功");
break;
}
}
account.Routes.Clear();
return GameErrorCode.Success;
}
public static async FTask<(uint error, long chatRouteId, int routeType)> OnlineChat(Scene scene, GameAccount account,long gateRouteId)
{
var chat = SceneConfigData.Instance.GetSceneBySceneType(scene.World.Id, SceneType.Chat)[0];
var response = (Chat2G_LoginResponse)await scene.NetworkMessagingComponent.CallInnerRoute(chat.RouteId, new G2Chat_LoginRequest()
@ -34,6 +58,6 @@ public static class GateLoginHelper
AccountId = account.Id,
GateRoutedId = gateRouteId,
});
return (response.ErrorCode, response.ChatUnitRunId,RouteType.ChatRoute);
return (response.ErrorCode, response.ChatRouteId,RouteType.ChatRoute);
}
}

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Hotfix")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f380af99fa15e1e6045b8a02edffb583f97f5687")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+47894751e0724034b829def7a67852359b02d23f")]
[assembly: System.Reflection.AssemblyProductAttribute("Hotfix")]
[assembly: System.Reflection.AssemblyTitleAttribute("Hotfix")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
436c800f2a052df15750ceb976c651e98650294588601754440113fe99f0e412
ac95efd761d72ed2f1c9cc0ba8fcf4764b049d05b7f62024c9fe14a561456187

View File

@ -1 +1 @@
84102f23287804c2542b10262a73a70ff16869e991ab05075dc69b3ae7613bfb
4dc5c869fdc172064f0a72a55682c5834c70f262475d8466efabaabf7701b043

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Main")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+f380af99fa15e1e6045b8a02edffb583f97f5687")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+47894751e0724034b829def7a67852359b02d23f")]
[assembly: System.Reflection.AssemblyProductAttribute("Main")]
[assembly: System.Reflection.AssemblyTitleAttribute("Main")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
b553cdeaf3cecd1b3fb8b442f83f44abb3507f4be5db3150b6d8136e84ec9e3c
f5791e4ee329f4d64c33f6ed979fb10299dfb1cbf8ac264c2337ed1a34b09d12