处理DotNet网络层对WebGL导出的兼容

处理DotNet网络层对WebGL导出的兼容
This commit is contained in:
ALEXTANG
2023-08-17 14:06:09 +08:00
parent 7c74e10857
commit 0661c59877
13 changed files with 37 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ namespace TEngine.Core.Network
{ {
None = 0, None = 0,
KCP = 1, KCP = 1,
TCP = 2 TCP = 2,
WebSocket = 3,
} }
} }

View File

@@ -2,7 +2,9 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Net; using System.Net;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
#if !UNITY_WEBGL
using System.Net.Sockets; using System.Net.Sockets;
#endif
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
@@ -49,6 +51,7 @@ namespace TEngine.Core
return $"{self.Address}:{self.Port}"; return $"{self.Address}:{self.Port}";
} }
#if !UNITY_WEBGL
public static void SetSioUdpConnReset(Socket socket) public static void SetSioUdpConnReset(Socket socket)
{ {
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -70,5 +73,6 @@ namespace TEngine.Core
socket.IOControl(SIO_UDP_CONNRESET, new[] {Convert.ToByte(false)}, null); socket.IOControl(SIO_UDP_CONNRESET, new[] {Convert.ToByte(false)}, null);
} }
#endif
} }
} }

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL
using System.Net.Sockets; using System.Net.Sockets;
namespace TEngine.Core.Network namespace TEngine.Core.Network
@@ -48,4 +49,5 @@ namespace TEngine.Core.Network
} }
} }
} }
} }
#endif

View File

@@ -13,7 +13,8 @@ namespace TEngine.Core.Network
public void Initialize(NetworkProtocolType networkProtocolType, NetworkTarget networkTarget) public void Initialize(NetworkProtocolType networkProtocolType, NetworkTarget networkTarget)
{ {
switch (networkProtocolType) switch (networkProtocolType)
{ {
#if !UNITY_WEBGL
case NetworkProtocolType.KCP: case NetworkProtocolType.KCP:
{ {
Network = new KCPClientNetwork(Scene, networkTarget); Network = new KCPClientNetwork(Scene, networkTarget);
@@ -24,6 +25,7 @@ namespace TEngine.Core.Network
Network = new TCPClientNetwork(Scene, networkTarget); Network = new TCPClientNetwork(Scene, networkTarget);
return; return;
} }
#endif
default: default:
{ {
throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}"); throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}");

View File

@@ -13,6 +13,7 @@ namespace TEngine.Core.Network
{ {
switch (networkProtocolType) switch (networkProtocolType)
{ {
#if !UNITY_WEBGL
case NetworkProtocolType.KCP: case NetworkProtocolType.KCP:
{ {
Network = new KCPServerNetwork(Scene, networkTarget, address); Network = new KCPServerNetwork(Scene, networkTarget, address);
@@ -25,6 +26,7 @@ namespace TEngine.Core.Network
// Log.Info($"NetworkProtocol:TCP IPEndPoint:{address}"); // Log.Info($"NetworkProtocol:TCP IPEndPoint:{address}");
return; return;
} }
#endif
default: default:
{ {
throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}"); throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}");

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL
using System; using System;
using System.Buffers; using System.Buffers;
using System.Collections.Generic; using System.Collections.Generic;
@@ -565,4 +566,5 @@ namespace TEngine.Core.Network
#endregion #endregion
} }
} }
#endif

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -459,4 +460,5 @@ namespace TEngine.Core.Network
#endregion #endregion
} }
} }
#endif

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL
using System; using System;
using System.Buffers; using System.Buffers;
using System.IO; using System.IO;
@@ -232,4 +233,5 @@ namespace TEngine.Core.Network
#endregion #endregion
} }
} }
#endif

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -538,4 +539,5 @@ namespace TEngine.Core.Network
#endregion #endregion
} }
} }
#endif

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@@ -235,4 +236,5 @@ namespace TEngine.Core.Network
#endregion #endregion
} }
} }
#endif

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL
using System; using System;
using System.IO; using System.IO;
using System.Net.Sockets; using System.Net.Sockets;
@@ -346,4 +347,5 @@ namespace TEngine.Core.Network
#endregion #endregion
} }
} }
#endif

View File

@@ -7,8 +7,6 @@ public partial class GameApp:Singleton<GameApp>
{ {
private static List<Assembly> _hotfixAssembly; private static List<Assembly> _hotfixAssembly;
public Scene Scene { private set; get; }
/// <summary> /// <summary>
/// 热更域App主入口。 /// 热更域App主入口。
/// </summary> /// </summary>

View File

@@ -22,6 +22,11 @@ public partial class GameApp
} }
/// <summary>
/// Entity框架根节点。
/// </summary>
public Scene Scene { private set; get; }
/// <summary> /// <summary>
/// 注册所有逻辑系统 /// 注册所有逻辑系统
/// </summary> /// </summary>