Structs.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.Text;
  4. namespace ENet
  5. {
  6. public enum EventType
  7. {
  8. None = 0,
  9. Connect = 1,
  10. Disconnect = 2,
  11. Receive = 3
  12. }
  13. public enum PeerState
  14. {
  15. Uninitialized = -1,
  16. Disconnected = 0,
  17. Connecting = 1,
  18. AcknowledgingConnect = 2,
  19. ConnectionPending = 3,
  20. ConnectionSucceeded = 4,
  21. Connected = 5,
  22. DisconnectLater = 6,
  23. Disconnecting = 7,
  24. AcknowledgingDisconnect = 8,
  25. Zombie = 9
  26. }
  27. [Flags]
  28. public enum PacketFlags
  29. {
  30. None = 0,
  31. Reliable = 1 << 0,
  32. Unsequenced = 1 << 1,
  33. NoAllocate = 1 << 2
  34. }
  35. [StructLayout(LayoutKind.Sequential)]
  36. public struct ENetAddress
  37. {
  38. public uint host;
  39. public ushort port;
  40. }
  41. [StructLayout(LayoutKind.Sequential)]
  42. public struct ENetCallbacks
  43. {
  44. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  45. public delegate IntPtr malloc_cb(IntPtr size);
  46. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  47. public delegate void free_cb(IntPtr memory);
  48. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  49. public delegate void no_memory_cb();
  50. public IntPtr malloc, free, no_memory;
  51. }
  52. [StructLayout(LayoutKind.Sequential)]
  53. public struct ENetCompressor
  54. {
  55. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  56. public delegate void compress_cb(
  57. IntPtr context, IntPtr inBuffers, IntPtr inBufferCount, IntPtr inLimit, IntPtr outData, IntPtr outLimit);
  58. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  59. public delegate void decompress_cb(IntPtr context, IntPtr inData, IntPtr inLimit, IntPtr outData, IntPtr outLimit);
  60. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  61. public delegate void destroy_cb(IntPtr context);
  62. public IntPtr context;
  63. public IntPtr compress, decompress, destroy;
  64. }
  65. [StructLayout(LayoutKind.Sequential)]
  66. public class ENetEvent
  67. {
  68. public EventType type;
  69. public IntPtr peer;
  70. public byte channelID;
  71. public uint data;
  72. public IntPtr packet;
  73. }
  74. [StructLayout(LayoutKind.Sequential)]
  75. public struct ENetHost
  76. {
  77. }
  78. [StructLayout(LayoutKind.Sequential)]
  79. public class ENetListNode
  80. {
  81. public ENetListNode next;
  82. public ENetListNode previous;
  83. }
  84. [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
  85. public delegate void ENetPacketFreeCallback(ref ENetPacket param0);
  86. [StructLayoutAttribute(LayoutKind.Sequential)]
  87. public struct ENetPacket
  88. {
  89. public uint referenceCount;
  90. public uint flags;
  91. [MarshalAsAttribute(UnmanagedType.LPStr)]
  92. public StringBuilder data;
  93. public uint dataLength;
  94. public ENetPacketFreeCallback freeCallback;
  95. }
  96. [StructLayout(LayoutKind.Sequential)]
  97. public struct ENetPeer
  98. {
  99. public ENetListNode dispatchList;
  100. public readonly IntPtr host;
  101. public readonly ushort outgoingPeerID;
  102. public readonly ushort incomingPeerID;
  103. public readonly uint connectID;
  104. public readonly byte outgoingSessionID;
  105. public readonly byte incomingSessionID;
  106. public ENetAddress address;
  107. public IntPtr data;
  108. public readonly PeerState state;
  109. }
  110. }