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 1314ec4 commit c7b17fd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 16 additions & 1 deletion GameFrameX.NetWork/BaseNetWorkChannel.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -38,6 +40,11 @@ public class BaseNetWorkChannel : INetWorkChannel
/// </summary>
public bool IsWebSocket { get; }

/// <summary>
/// 设置
/// </summary>
public AppSetting Setting { get; }

/// <summary>
/// WebSocket会话
/// </summary>
Expand All @@ -47,13 +54,17 @@ public class BaseNetWorkChannel : INetWorkChannel
/// 初始化
/// </summary>
/// <param name="session"></param>
/// <param name="setting"></param>
/// <param name="messageEncoder"></param>
/// <param name="rpcSession"></param>
/// <param name="isWebSocket"></param>
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)
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 3 additions & 1 deletion GameFrameX.NetWork/DefaultNetWorkChannel.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GameFrameX.NetWork.Abstractions;
using GameFrameX.Setting;
using GameFrameX.SuperSocket.Server.Abstractions.Session;

namespace GameFrameX.NetWork;
Expand All @@ -12,10 +13,11 @@ public class DefaultNetWorkChannel : BaseNetWorkChannel
/// 初始化
/// </summary>
/// <param name="session"></param>
/// <param name="setting"></param>
/// <param name="messageEncoder"></param>
/// <param name="rpcSession"></param>
/// <param name="isWebSocket"></param>
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)
{
}
}

0 comments on commit c7b17fd

Please sign in to comment.