处理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,
KCP = 1,
TCP = 2
TCP = 2,
WebSocket = 3,
}
}

View File

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

View File

@@ -1,3 +1,4 @@
#if !UNITY_WEBGL
using System.Net.Sockets;
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)
{
switch (networkProtocolType)
{
{
#if !UNITY_WEBGL
case NetworkProtocolType.KCP:
{
Network = new KCPClientNetwork(Scene, networkTarget);
@@ -24,6 +25,7 @@ namespace TEngine.Core.Network
Network = new TCPClientNetwork(Scene, networkTarget);
return;
}
#endif
default:
{
throw new NotSupportedException($"Unsupported NetworkProtocolType:{networkProtocolType}");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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