Skip to content

Commit 7cc21b9

Browse files
committed
[增加]1. 增加服务器的实例ID的字段和处理
1 parent 7988d07 commit 7cc21b9

5 files changed

Lines changed: 21 additions & 3 deletions

File tree

GameFrameX.ServerManager/NamingServiceManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void AddSelf(AppSetting setting)
159159
return;
160160
}
161161

162-
SelfServiceInfo = new ServiceInfo(setting.ServerType, null, string.Empty, setting.ServerName, setting.ServerId, setting.InnerIp, setting.InnerPort, setting.OuterIp, setting.OuterPort);
162+
SelfServiceInfo = new ServiceInfo(setting.ServerType, null, string.Empty, setting.ServerName, setting.ServerId, setting.ServerInstanceId, setting.InnerIp, setting.InnerPort, setting.OuterIp, setting.OuterPort);
163163
_serverMap[SelfServiceInfo.ServerId] = SelfServiceInfo;
164164
}
165165

GameFrameX.ServerManager/ServiceInfo.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ public sealed class ServiceInfo : IServiceInfo
1717
/// <param name="sessionId"></param>
1818
/// <param name="serverName"></param>
1919
/// <param name="serverId"></param>
20+
/// <param name="serverInstanceId"></param>
2021
/// <param name="innerIp"></param>
2122
/// <param name="innerPort"></param>
2223
/// <param name="outerIp"></param>
2324
/// <param name="outerPort"></param>
24-
public ServiceInfo(ServerType type, object session, string sessionId, string serverName, long serverId, string innerIp, ushort innerPort, string outerIp, ushort outerPort)
25+
public ServiceInfo(ServerType type, object session, string sessionId, string serverName, long serverId, long serverInstanceId, string innerIp, ushort innerPort, string outerIp, ushort outerPort)
2526
{
2627
Type = type;
2728
Session = session;
@@ -32,6 +33,7 @@ public ServiceInfo(ServerType type, object session, string sessionId, string ser
3233
OuterIp = outerIp;
3334
OuterPort = outerPort;
3435
SessionId = sessionId;
36+
ServerInstanceId = serverInstanceId;
3537
StatusInfo = new ServiceStatusInfo();
3638
}
3739

@@ -86,6 +88,11 @@ public ServiceInfo(ServerType type, object session, string sessionId, string ser
8688
/// </summary>
8789
public long ServerId { get; }
8890

91+
/// <summary>
92+
/// 服务器实例ID
93+
/// </summary>
94+
public long ServerInstanceId { get; set; }
95+
8996
/// <summary>
9097
/// 转换为字符串
9198
/// </summary>

GameFrameX.StartUp/AppStartUpByServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ private async Task StartServer<TMessageDecoderHandler>(List<BaseHttpHandler> bas
319319
{
320320
config.ServiceName = Setting.ServerName + "-" + Setting.TagName;
321321
config.ServiceVersion = Assembly.GetCallingAssembly().ImageRuntimeVersion;
322-
config.ServiceInstanceId = Setting.ServerId.ToString();
322+
config.ServiceInstanceId = Setting.ServerId + "-" + Setting.ServerInstanceId;
323323
config.DeploymentEnvironment = EnvironmentHelper.GetEnvironmentName().IsNullOrEmpty() ? Setting.IsDebug ? "Debug" : "Release" : EnvironmentHelper.GetEnvironmentName();
324324
})
325325
.Build();

GameFrameX.StartUp/Options/LauncherOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ public sealed class LauncherOptions
9393
[Option(nameof(ServerId), HelpText = "服务器ID")]
9494
public int ServerId { get; set; }
9595

96+
/// <summary>
97+
/// 服务器实例ID
98+
/// </summary>
99+
[Option(nameof(ServerInstanceId), HelpText = "服务器实例ID")]
100+
public long ServerInstanceId { get; set; }
101+
96102
/// <summary>
97103
/// 保存数据间隔, 单位毫秒,默认300秒/5分钟
98104
/// </summary>

GameFrameX.Utility/Setting/AppSetting.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,11 @@ public string ToFormatString()
183183
/// </summary>
184184
public int ServerId { get; set; }
185185

186+
/// <summary>
187+
/// 服务器实例ID
188+
/// </summary>
189+
public long ServerInstanceId { get; set; }
190+
186191
/// <summary>
187192
/// 服务器名称
188193
/// </summary>

0 commit comments

Comments
 (0)