|
@@ -10,72 +10,35 @@ namespace ET.Server
|
|
|
public static class RouterComponentSystem
|
|
|
{
|
|
|
[ObjectSystem]
|
|
|
- public class RandomGeneratorponentAwakeSystem: AwakeSystem<RouterComponent, IPEndPoint, string, NetworkProtocol>
|
|
|
+ public class RandomGeneratorponentAwakeSystem: AwakeSystem<RouterComponent, IPEndPoint, string>
|
|
|
{
|
|
|
- protected override void Awake(RouterComponent self, IPEndPoint ipEndPoint, string innerIP, NetworkProtocol protocol)
|
|
|
+ protected override void Awake(RouterComponent self, IPEndPoint ipEndPoint, string innerIP)
|
|
|
{
|
|
|
- switch (protocol)
|
|
|
+ self.OuterSocket = new Socket(ipEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
|
|
|
+ self.OuterSocket.Bind(new IPEndPoint(IPAddress.Any, ipEndPoint.Port));
|
|
|
+ if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
|
{
|
|
|
- case NetworkProtocol.KCP:
|
|
|
- {
|
|
|
- self.OuterSocket = new Socket(ipEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
|
|
|
- self.OuterSocket.Bind(new IPEndPoint(IPAddress.Any, ipEndPoint.Port));
|
|
|
-
|
|
|
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
|
- {
|
|
|
- self.OuterSocket.SendBufferSize = 16 * Kcp.OneM;
|
|
|
- self.OuterSocket.ReceiveBufferSize = 16 * Kcp.OneM;
|
|
|
- }
|
|
|
+ self.OuterSocket.SendBufferSize = 16 * Kcp.OneM;
|
|
|
+ self.OuterSocket.ReceiveBufferSize = 16 * Kcp.OneM;
|
|
|
+ }
|
|
|
|
|
|
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
- {
|
|
|
- const uint IOC_IN = 0x80000000;
|
|
|
- const uint IOC_VENDOR = 0x18000000;
|
|
|
- uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
|
|
|
+ self.InnerSocket = new Socket(ipEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
|
|
|
+ self.InnerSocket.Bind(new IPEndPoint(IPAddress.Any, 0));
|
|
|
|
|
|
- self.OuterSocket.IOControl((int) SIO_UDP_CONNRESET, new[] { Convert.ToByte(false) }, null);
|
|
|
- // self.InnerSocket.IOControl((int) SIO_UDP_CONNRESET, new[] { Convert.ToByte(false) }, null);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- case NetworkProtocol.TCP:
|
|
|
- {
|
|
|
- self.OuterSocket = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
|
|
- self.OuterSocket.Bind(new IPEndPoint(IPAddress.Any, ipEndPoint.Port));
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
|
+ {
|
|
|
+ self.InnerSocket.SendBufferSize = 16 * Kcp.OneM;
|
|
|
+ self.InnerSocket.ReceiveBufferSize = 16 * Kcp.OneM;
|
|
|
}
|
|
|
|
|
|
- NetworkProtocol innerProtocol = NetInnerComponent.Instance.GetProtocol();
|
|
|
- switch (innerProtocol)
|
|
|
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
{
|
|
|
- case NetworkProtocol.KCP:
|
|
|
- {
|
|
|
- self.InnerSocket = new Socket(ipEndPoint.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
|
|
|
- self.InnerSocket.Bind(new IPEndPoint(IPAddress.Any, 0));
|
|
|
-
|
|
|
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
|
|
- {
|
|
|
- self.InnerSocket.SendBufferSize = 16 * Kcp.OneM;
|
|
|
- self.InnerSocket.ReceiveBufferSize = 16 * Kcp.OneM;
|
|
|
- }
|
|
|
-
|
|
|
- if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
|
- {
|
|
|
- const uint IOC_IN = 0x80000000;
|
|
|
- const uint IOC_VENDOR = 0x18000000;
|
|
|
- uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
|
|
|
+ const uint IOC_IN = 0x80000000;
|
|
|
+ const uint IOC_VENDOR = 0x18000000;
|
|
|
+ uint SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12;
|
|
|
|
|
|
- self.InnerSocket.IOControl((int) SIO_UDP_CONNRESET, new[] { Convert.ToByte(false) }, null);
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- case NetworkProtocol.TCP:
|
|
|
- {
|
|
|
- self.InnerSocket = new Socket(ipEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
|
|
|
- self.InnerSocket.Bind(new IPEndPoint(IPAddress.Any, 0));
|
|
|
- break;
|
|
|
- }
|
|
|
+ self.OuterSocket.IOControl((int) SIO_UDP_CONNRESET, new[] { Convert.ToByte(false) }, null);
|
|
|
+ self.InnerSocket.IOControl((int) SIO_UDP_CONNRESET, new[] { Convert.ToByte(false) }, null);
|
|
|
}
|
|
|
}
|
|
|
}
|