Skip to content

Commit 4a885aa

Browse files
committed
refactor: 适配 Core 层 API 变更
- 配置查询从 Get().IsNull() 迁移至 TryGet() 模式 - CreateTime 属性重命名为 CreatedTime - DefaultNetWorkChannel 构造函数简化 - GlobalConst 迁移至 GameServerConst - TimerHelper.GetUtcNow() 迁移至 GetNowWithUtc() - 移除 DiscoveryCenter 相关配置和属性
1 parent 9464702 commit 4a885aa

7 files changed

Lines changed: 11 additions & 18 deletions

File tree

GameFrameX.Hotfix/Logic/Http/Bag/ReqPlayerSendItemHttpHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public override async Task<string> Action(string ip, string url, HttpMessageRequ
5959
{
6060
foreach (var item in request.Items)
6161
{
62-
if (tbItemConfig.Get(item.Key).IsNull())
62+
if (!tbItemConfig.TryGet(item.Key, out var itemConfigState))
6363
{
6464
continue;
6565
}

GameFrameX.Hotfix/Logic/Http/Player/ReqLoginHttpHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public override async Task<MessageObject> Action(string ip, string url, Dictiona
6666

6767
// 构建账号登录返回信息
6868
respLogin.Code = loginState.State;
69-
respLogin.CreateTime = loginState.CreateTime;
69+
respLogin.CreateTime = loginState.CreatedTime;
7070
respLogin.Level = loginState.Level;
7171
respLogin.Id = loginState.Id;
7272
respLogin.RoleName = loginState.NickName;

GameFrameX.Hotfix/Logic/Player/Bag/BagComponentAgent.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ public async Task OnAddBagItem(INetWorkChannel netWorkChannel, ReqAddItem messag
5151
// 校验物品是否存在
5252
foreach (var item in message.ItemDic)
5353
{
54-
var hasItem = ConfigComponent.Instance.GetConfig<TbItemConfig>().Get((int)item.Key);
55-
if (hasItem.IsNull())
54+
if (!ConfigComponent.Instance.GetConfig<TbItemConfig>().TryGet(item.Key, out var itemConfigState))
5655
{
5756
response.ErrorCode = (int)OperationStatusCode.NotFound;
5857
return;
@@ -113,8 +112,7 @@ public async Task OnRemoveBagItem(INetWorkChannel netWorkChannel, ReqRemoveItem
113112
// 校验物品是否存在
114113
foreach (var item in message.ItemDic)
115114
{
116-
var hasItem = ConfigComponent.Instance.GetConfig<TbItemConfig>().Get((int)item.Key);
117-
if (hasItem.IsNull())
115+
if (!ConfigComponent.Instance.GetConfig<TbItemConfig>().TryGet(item.Key, out var itemConfigState))
118116
{
119117
response.ErrorCode = (int)OperationStatusCode.NotFound;
120118
return;
@@ -156,8 +154,7 @@ public async Task OnRemoveBagItem(INetWorkChannel netWorkChannel, ReqRemoveItem
156154
public async Task OnUseBagItem(INetWorkChannel netWorkChannel, ReqUseItem message, RespUseItem response)
157155
{
158156
// 校验物品是否存在
159-
var hasItem = ConfigComponent.Instance.GetConfig<TbItemConfig>().Get(message.ItemId);
160-
if (hasItem.IsNull())
157+
if (!ConfigComponent.Instance.GetConfig<TbItemConfig>().TryGet(message.ItemId, out var itemConfigState))
161158
{
162159
response.ErrorCode = (int)OperationStatusCode.NotFound;
163160
return;

GameFrameX.Hotfix/Logic/Player/Login/PlayerComponentAgent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public async Task OnPlayerLogin(INetWorkChannel workChannel, PlayerState playerS
6161
// 更新连接会话数据
6262
SessionManager.UpdateSession(workChannel.GameAppSession.SessionID, playerState.Id, playerState.Id.ToString());
6363
response.Code = playerState.State;
64-
response.CreateTime = playerState.CreateTime;
64+
response.CreateTime = playerState.CreatedTime;
6565
response.PlayerInfo = new PlayerInfo
6666
{
6767
Id = playerState.Id,

GameFrameX.Hotfix/StartUp/AppStartUpHotfixGameByEntry.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ namespace GameFrameX.Hotfix.StartUp;
3636

3737
internal partial class AppStartUpHotfixGame : AppStartUpBase, IHotfixBridge
3838
{
39-
protected override bool IsRegisterToDiscoveryCenter { get; set; } = false;
40-
4139
public async Task<bool> OnLoadSuccess(AppSetting setting, bool reload)
4240
{
4341
if (reload)

GameFrameX.Hotfix/StartUp/AppStartUpHotfixGameByMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ protected override ValueTask OnDisconnected(IAppSession appSession, CloseEventAr
7474
protected override async ValueTask OnConnected(IAppSession appSession)
7575
{
7676
LogHelper.Info("有外部客户端网络连接成功!。链接信息:SessionID:" + appSession.SessionID + " RemoteEndPoint:" + appSession.RemoteEndPoint);
77-
var netChannel = new DefaultNetWorkChannel(appSession, Setting, null, appSession is WebSocketSession);
77+
var netChannel = new DefaultNetWorkChannel(appSession, Setting);
7878
var count = SessionManager.Count();
7979
if (count > Setting.MaxClientCount)
8080
{

GameFrameX.Launcher/StartUp/AppStartUpGame.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace GameFrameX.Launcher.StartUp;
3737
/// <summary>
3838
/// 游戏服务器
3939
/// </summary>
40-
[StartUpTag(GlobalConst.GameServiceName)]
40+
[StartUpTag(GameServerConst.Game.Name)]
4141
internal sealed class AppStartUpGame : AppStartUpBase
4242
{
4343
public override async Task StartAsync()
@@ -74,7 +74,7 @@ public override async Task StartAsync()
7474
LogHelper.DebugConsole("加载热更新模块结束...");
7575

7676
LogHelper.DebugConsole("进入游戏主循环...");
77-
GlobalSettings.LaunchTime = TimerHelper.GetUtcNow();
77+
GlobalSettings.LaunchTime = TimerHelper.GetNowWithUtc();
7878
GlobalSettings.IsAppRunning = true;
7979
LogHelper.Info($"服务器{Setting.ServerType}启动结束...");
8080
exitMessage = await AppExitToken;
@@ -96,8 +96,8 @@ protected override void Init()
9696
{
9797
Setting = new AppSetting
9898
{
99-
ServerId = GlobalConst.GameServiceServerId,
100-
ServerType = GlobalConst.GameServiceName,
99+
ServerId = GameServerConst.Game.Id,
100+
ServerType = GameServerConst.Game.Name,
101101
IsEnableTcp = true,
102102
InnerPort = 29100,
103103
MetricsPort = 29090,
@@ -107,9 +107,7 @@ protected override void Init()
107107
MinModuleId = 10,
108108
HttpIsDevelopment = true,
109109
MaxModuleId = 9999,
110-
DiscoveryCenterHost = "127.0.0.1",
111110
TagName = "GameFrameX",
112-
DiscoveryCenterPort = 21001,
113111
DataBaseUrl = "mongodb+srv://gameframex:f9v42aU9DVeFNfAF@gameframex.8taphic.mongodb.net/?retryWrites=true&w=majority",
114112
DataBaseName = "gameframex",
115113
};

0 commit comments

Comments
 (0)