提交 4f37269f 编写于 作者: T tanghai

enet mtu 改成512,启用crc校验

上级 8ce25cc1
......@@ -208,7 +208,7 @@ enum
ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024,
ENET_HOST_SEND_BUFFER_SIZE = 256 * 1024,
ENET_HOST_BANDWIDTH_THROTTLE_INTERVAL = 1000,
ENET_HOST_DEFAULT_MTU = 1400,
ENET_HOST_DEFAULT_MTU = 512,
ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE = 32 * 1024 * 1024,
ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA = 32 * 1024 * 1024,
......
......@@ -102,6 +102,7 @@ enet_host_create (const ENetAddress * address, size_t peerCount, size_t channelL
host -> duplicatePeers = ENET_PROTOCOL_MAXIMUM_PEER_ID;
host -> maximumPacketSize = ENET_HOST_DEFAULT_MAXIMUM_PACKET_SIZE;
host -> maximumWaitingData = ENET_HOST_DEFAULT_MAXIMUM_WAITING_DATA;
host->checksum = enet_crc32;
host -> compressor.context = NULL;
host -> compressor.compress = NULL;
......
......@@ -89,11 +89,6 @@ namespace UNet
}
}
public void EnableCrc()
{
NativeMethods.EnetEnableCrc(this.host);
}
private EEvent GetEvent()
{
var enetEv = new ENetEvent();
......@@ -102,7 +97,7 @@ namespace UNet
{
return null;
}
var e = new EEvent(enetEv);
EEvent e = new EEvent(enetEv);
return e;
}
......
......@@ -44,9 +44,6 @@ namespace UNet
EntryPoint = "enet_initialize_with_callbacks")]
internal static extern int EnetInitializeWithCallbacks(uint version, ref ENetCallbacks inits);
[DllImport(LIB, CallingConvention = CallingConvention.Cdecl, EntryPoint = "enet_enable_crc")]
internal static extern void EnetEnableCrc(IntPtr host);
[DllImport(LIB, CallingConvention = CallingConvention.Cdecl, EntryPoint = "enet_host_create")]
internal static extern IntPtr EnetHostCreate(
ref ENetAddress address, uint peerLimit, uint channelLimit, uint incomingBandwidth,
......
......@@ -52,7 +52,8 @@ namespace UNet
{
return new ENetPeer();
}
return (ENetPeer) Marshal.PtrToStructure(this.peerPtr, typeof (ENetPeer));
ENetPeer peer = (ENetPeer) Marshal.PtrToStructure(this.peerPtr, typeof (ENetPeer));
return peer;
}
set
{
......@@ -175,11 +176,11 @@ namespace UNet
// 如果有缓存的包,从缓存中取
if (this.recvBuffer.Count > 0)
{
var bytes = this.recvBuffer.First.Value;
byte[] bytes = this.recvBuffer.First.Value;
this.recvBuffer.RemoveFirst();
tcs.TrySetResult(bytes);
}
// 没有缓存封包,设置回调等待
// 没有缓存封包,设置回调等待
else
{
this.Received = eEvent =>
......@@ -189,9 +190,9 @@ namespace UNet
tcs.TrySetException(new EException("socket disconnected in receive"));
}
using (var packet = new EPacket(eEvent.PacketPtr))
using (EPacket packet = new EPacket(eEvent.PacketPtr))
{
var bytes = packet.Bytes;
byte[] bytes = packet.Bytes;
tcs.TrySetResult(bytes);
}
};
......
......@@ -6,7 +6,7 @@ namespace ENetExe
{
private static void Main(string[] args)
{
var test = new UNetClientServerTest();
var test = new UServiceTest();
test.ClientSendToServer();
}
}
......
......@@ -54,7 +54,7 @@
</Otherwise>
</Choose>
<ItemGroup>
<Compile Include="UNetClientServerTest.cs" />
<Compile Include="UServiceTest.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj">
......
......@@ -9,7 +9,7 @@ using Network;
namespace UNetTest
{
[TestClass]
public class UNetClientServerTest
public class UServiceTest
{
private readonly Barrier barrier = new Barrier(3);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册