Skip to content

Commit

Permalink
[修改]1. 修改设置参数的适配
Browse files Browse the repository at this point in the history
  • Loading branch information
AlianBlank committed Jul 29, 2024
1 parent 87598a8 commit 1756d8d
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions GameFrameX.Hotfix/Common/HotfixBridgeByServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ public async void RunServer(bool reload)
private async Task StartServer()
{
webSocketServer = WebSocketHostBuilder.Create()
.UseWebSocketMessageHandler(WebSocketMessageHandler)
.UseSessionHandler(OnConnected, OnDisconnected)
.ConfigureAppConfiguration((Action<HostBuilderContext, IConfigurationBuilder>)(ConfigureWebServer)).Build();
.UseWebSocketMessageHandler(WebSocketMessageHandler)
.UseSessionHandler(OnConnected, OnDisconnected)
.ConfigureAppConfiguration((Action<HostBuilderContext, IConfigurationBuilder>)(ConfigureWebServer)).Build();
await webSocketServer.StartAsync();
LogHelper.Info("启动 WebSocket 服务器完成...");
tcpService = SuperSocketHostBuilder.Create<INetworkMessage, MessageObjectPipelineFilter>()
.ConfigureSuperSocket(ConfigureSuperSocket)
.UseClearIdleSession()
.UsePackageDecoder<BaseMessageDecoderHandler>()
.UseSessionHandler(OnConnected, OnDisconnected)
.UsePackageHandler(MessagePackageHandler, ClientErrorHandler)
.UseInProcSessionContainer()
.BuildAsServer();
.ConfigureSuperSocket(ConfigureSuperSocket)
.UseClearIdleSession()
.UsePackageDecoder<BaseMessageDecoderHandler>()
.UseSessionHandler(OnConnected, OnDisconnected)
.UsePackageHandler(MessagePackageHandler, ClientErrorHandler)
.UseInProcSessionContainer()
.BuildAsServer();

await tcpService.StartAsync();
LogHelper.Info("启动 TCP 服务器完成...");
Expand Down Expand Up @@ -92,7 +92,8 @@ private ValueTask OnDisconnected(IAppSession appSession, CloseEventArgs disconne
private ValueTask OnConnected(IAppSession appSession)
{
LogHelper.Info("有外部客户端网络连接成功!。链接信息:SessionID:" + appSession.SessionID + " RemoteEndPoint:" + appSession.RemoteEndPoint);
var netChannel = new DefaultNetWorkChannel(appSession, messageEncoderHandler, null, appSession is WebSocketSession);

var netChannel = new DefaultNetWorkChannel(appSession, Setting, messageEncoderHandler, null, appSession is WebSocketSession);
GameClientSessionManager.SetSession(appSession.SessionID, netChannel); //移除

return ValueTask.CompletedTask;
Expand All @@ -114,8 +115,8 @@ private async ValueTask WebSocketMessageHandler(WebSocketSession session, WebSoc
return;
}

var bytes = message.Data;
var buffer = bytes.ToArray();
var bytes = message.Data;
var buffer = bytes.ToArray();
var messageObject = messageDecoderHandler.Handler(buffer);
await MessagePackageHandler(session, messageObject);
}
Expand All @@ -129,10 +130,9 @@ private async ValueTask MessagePackageHandler(IAppSession appSession, INetworkMe
{
if (messageObject is MessageObject message)
{
var messageId = message.MessageId;
if (Setting.IsDebug && Setting.IsDebugReceive)
{
LogHelper.Debug($"---收到消息:[{messageId},{message.GetType().Name}] 消息内容:[{messageObject}]");
LogHelper.Debug($"---收到{messageObject.ToFormatMessageString()}");
}

var handler = HotfixManager.GetTcpHandler(message.MessageId);
Expand All @@ -142,7 +142,7 @@ private async ValueTask MessagePackageHandler(IAppSession appSession, INetworkMe
return;
}

handler.Message = message;
handler.Message = message;
handler.NetWorkChannel = GameClientSessionManager.GetSession(appSession.SessionID);
await handler.Init();
await handler.InnerAction();
Expand All @@ -152,7 +152,7 @@ private async ValueTask MessagePackageHandler(IAppSession appSession, INetworkMe
private void ConfigureWebServer(HostBuilderContext context, IConfigurationBuilder builder)
{
builder.AddInMemoryCollection(new Dictionary<string, string>()
{ { "serverOptions:name", "GameServer" }, { "serverOptions:listeners:0:ip", "Any" }, { "serverOptions:listeners:0:port", Setting.WsPort.ToString() } });
{ { "serverOptions:name", "GameServer" }, { "serverOptions:listeners:0:ip", "Any" }, { "serverOptions:listeners:0:port", Setting.WsPort.ToString() } });
}

public async Task StopServer()
Expand Down

0 comments on commit 1756d8d

Please sign in to comment.