From c7b17fdc17aaa044b57354ff67bd274588e6e153 Mon Sep 17 00:00:00 2001 From: AlianBlank Date: Mon, 29 Jul 2024 18:16:06 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=A2=9E=E5=8A=A0]1.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=BD=91=E7=BB=9C=E6=B8=A0=E9=81=93=E7=9A=84=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GameFrameX.NetWork/BaseNetWorkChannel.cs | 17 ++++++++++++++++- GameFrameX.NetWork/DefaultNetWorkChannel.cs | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/GameFrameX.NetWork/BaseNetWorkChannel.cs b/GameFrameX.NetWork/BaseNetWorkChannel.cs index e5a4874b..10ccdcdd 100644 --- a/GameFrameX.NetWork/BaseNetWorkChannel.cs +++ b/GameFrameX.NetWork/BaseNetWorkChannel.cs @@ -1,7 +1,9 @@ using System.Collections.Concurrent; using GameFrameX.Extension; +using GameFrameX.Log; using GameFrameX.NetWork.Abstractions; using GameFrameX.NetWork.Messages; +using GameFrameX.Setting; using GameFrameX.SuperSocket.Server.Abstractions.Session; using GameFrameX.SuperSocket.WebSocket.Server; using GameFrameX.Utility; @@ -38,6 +40,11 @@ public class BaseNetWorkChannel : INetWorkChannel /// public bool IsWebSocket { get; } + /// + /// 设置 + /// + public AppSetting Setting { get; } + /// /// WebSocket会话 /// @@ -47,13 +54,17 @@ public class BaseNetWorkChannel : INetWorkChannel /// 初始化 /// /// + /// /// /// /// - public BaseNetWorkChannel(IGameAppSession session, IMessageEncoderHandler messageEncoder, IRpcSession rpcSession, bool isWebSocket) + public BaseNetWorkChannel(IGameAppSession session, AppSetting setting, IMessageEncoderHandler messageEncoder, IRpcSession rpcSession, bool isWebSocket) { + setting.CheckNotNull(nameof(setting)); + messageEncoder.CheckNotNull(nameof(messageEncoder)); Session = session; IsWebSocket = isWebSocket; + Setting = setting; _messageEncoder = messageEncoder; RpcSession = rpcSession; if (isWebSocket) @@ -83,6 +94,10 @@ public virtual async Task WriteAsync(IMessage messageObject, int uniId = 0, int messageObject.CheckNotNull(nameof(messageObject)); var messageData = _messageEncoder.Handler(messageObject); + if (Setting.IsDebug && Setting.IsDebugSend) + { + LogHelper.Debug($"---发送{messageObject.ToFormatMessageString()}"); + } if (IsWebSocket) { diff --git a/GameFrameX.NetWork/DefaultNetWorkChannel.cs b/GameFrameX.NetWork/DefaultNetWorkChannel.cs index 25a8591d..ca606a61 100644 --- a/GameFrameX.NetWork/DefaultNetWorkChannel.cs +++ b/GameFrameX.NetWork/DefaultNetWorkChannel.cs @@ -1,4 +1,5 @@ using GameFrameX.NetWork.Abstractions; +using GameFrameX.Setting; using GameFrameX.SuperSocket.Server.Abstractions.Session; namespace GameFrameX.NetWork; @@ -12,10 +13,11 @@ public class DefaultNetWorkChannel : BaseNetWorkChannel /// 初始化 /// /// + /// /// /// /// - public DefaultNetWorkChannel(IGameAppSession session, IMessageEncoderHandler messageEncoder, IRpcSession rpcSession = null, bool isWebSocket = false) : base(session, messageEncoder, rpcSession, isWebSocket) + public DefaultNetWorkChannel(IGameAppSession session, AppSetting setting, IMessageEncoderHandler messageEncoder, IRpcSession rpcSession = null, bool isWebSocket = false) : base(session,setting, messageEncoder, rpcSession, isWebSocket) { } } \ No newline at end of file