Răsfoiți Sursa

修复enet单元测试,crc校验和压缩不放到构造函数中开启,而是调用单独的函数开启

tanghai 13 ani în urmă
părinte
comite
83916c681e

+ 5 - 0
CSharp/App/BossClient/BossClient.cs

@@ -12,6 +12,11 @@ namespace BossClient
 
 		private readonly ClientHost clientHost = new ClientHost();
 
+		public BossClient()
+		{
+			this.clientHost.EnableCrc();
+		}
+
 		public void Dispose()
 		{
 			this.clientHost.Dispose();

+ 1 - 12
CSharp/Platform/ENet/ClientHost.cs

@@ -8,8 +8,7 @@ namespace ENet
 	{
 		public ClientHost(
 			uint peerLimit = NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID, uint channelLimit = 0,
-			uint incomingBandwidth = 0, uint outgoingBandwidth = 0, bool enableCrc = true,
-			bool compressWithRangeEncoder = false)
+			uint incomingBandwidth = 0, uint outgoingBandwidth = 0)
 		{
 			if (peerLimit > NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID)
 			{
@@ -24,16 +23,6 @@ namespace ENet
 			{
 				throw new ENetException("Host creation call failed.");
 			}
-
-			if (enableCrc)
-			{
-				this.EnableCrc();
-			}
-
-			if (compressWithRangeEncoder)
-			{
-				this.CompressWithRangeCoder();
-			}
 		}
 
 		public Task<Peer> ConnectAsync(string hostName, ushort port, 

+ 2 - 2
CSharp/Platform/ENet/Host.cs

@@ -47,7 +47,7 @@ namespace ENet
 			this.host = IntPtr.Zero;
 		}
 
-		protected void EnableCrc()
+		public void EnableCrc()
 		{
 			NativeMethods.enet_enable_crc(this.host);
 		}
@@ -86,7 +86,7 @@ namespace ENet
 			NativeMethods.enet_host_broadcast(this.host, channelID, packet.PacketPtr);
 		}
 
-		protected void CompressWithRangeCoder()
+		public void CompressWithRangeCoder()
 		{
 			NativeMethods.enet_host_compress_with_range_coder(this.host);
 		}

+ 1 - 12
CSharp/Platform/ENet/ServerHost.cs

@@ -7,8 +7,7 @@ namespace ENet
 	{
 		public ServerHost(string hostName, ushort port, 
 			uint peerLimit = NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID,
-			uint channelLimit = 0, uint incomingBandwidth = 0, uint outgoingBandwidth = 0,
-			bool enableCrc = true, bool compressWithRangeEncoder = true)
+			uint channelLimit = 0, uint incomingBandwidth = 0, uint outgoingBandwidth = 0)
 		{
 			if (peerLimit > NativeMethods.ENET_PROTOCOL_MAXIMUM_PEER_ID)
 			{
@@ -26,16 +25,6 @@ namespace ENet
 			{
 				throw new ENetException("Host creation call failed.");
 			}
-
-			if (enableCrc)
-			{
-				this.EnableCrc();
-			}
-
-			if (compressWithRangeEncoder)
-			{
-				this.CompressWithRangeCoder();
-			}
 		}
 
 		public Task<Peer> AcceptAsync()