Skip to content

Commit

Permalink
[增加]1. 增加强制设置为WebSocket 的宏定义配置
Browse files Browse the repository at this point in the history
  • Loading branch information
AlianBlank committed Oct 11, 2024
1 parent 1614261 commit b846ddb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Editor/NetworkLogScriptingDefineSymbols.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,25 @@ public static class NetworkLogScriptingDefineSymbols
{
private const string EnableNetworkReceiveLogScriptingDefineSymbol = "ENABLE_GAMEFRAMEX_NETWORK_RECEIVE_LOG";
private const string EnableNetworkSendLogScriptingDefineSymbol = "ENABLE_GAMEFRAMEX_NETWORK_SEND_LOG";
private const string ForceEnableNetworkSendLogScriptingDefineSymbol = "FORCE_ENABLE_GAME_FRAME_X_WEB_SOCKET";

/// <summary>
/// 禁用网络强制为WebSocket脚本宏定义。
/// </summary>
[MenuItem("GameFrameX/Log Scripting Define Symbols/Disable Force WebSocket", false, 105)]
public static void DisableForceWebSocketNetwork()
{
ScriptingDefineSymbols.RemoveScriptingDefineSymbol(ForceEnableNetworkSendLogScriptingDefineSymbol);
}

/// <summary>
/// 开启网络强制为WebSocket脚本宏定义。
/// </summary>
[MenuItem("GameFrameX/Log Scripting Define Symbols/Enable Force WebSocket", false, 106)]
public static void EnableForceWebSocketNetwork()
{
ScriptingDefineSymbols.AddScriptingDefineSymbol(ForceEnableNetworkSendLogScriptingDefineSymbol);
}

/// <summary>
/// 禁用网络接收日志脚本宏定义。
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Network/Network/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public INetworkChannel CreateNetworkChannel(string channelName, INetworkChannelH
{
throw new GameFrameworkException(Utility.Text.Format("Already exist network channel '{0}'.", channelName ?? string.Empty));
}
#if ENABLE_GAME_FRAME_X_WEB_SOCKET && UNITY_WEBGL
#if (ENABLE_GAME_FRAME_X_WEB_SOCKET && UNITY_WEBGL) || FORCE_ENABLE_GAME_FRAME_X_WEB_SOCKET
NetworkChannelBase networkChannel = new WebSocketNetworkChannel(channelName, networkChannelHelper);
#else
NetworkChannelBase networkChannel = new SystemTcpNetworkChannel(channelName, networkChannelHelper);
Expand Down

0 comments on commit b846ddb

Please sign in to comment.