internal ENetPacket(Native.ENetPacket *packet, byte channel) { Channel = channel; Flags = packet->Flags; m_Payload = new byte[packet->DataLength.ToUInt32()]; fixed(byte *dest = m_Payload) { Platform.Current.MemoryCopy((IntPtr)dest, (IntPtr)packet->Data, packet->DataLength); } }
public bool Receive(out ENetPacket packet) { byte channel = 0; Native.ENetPacket *native = LibENet.PeerReceive(Unsafe, &channel); if (((IntPtr)native) == IntPtr.Zero) { packet = null; return(false); } packet = new ENetPacket(native, channel); LibENet.PacketDestroy(native); return(true); }