Structs.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. public enum AddressType
  28. {
  29. IPv4 = 0
  30. }
  31. [Flags]
  32. public enum PacketFlags
  33. {
  34. None = 0,
  35. Reliable = 1 << 0,
  36. Unsequenced = 1 << 1,
  37. NoAllocate = 1 << 2
  38. }
  39. [StructLayout(LayoutKind.Sequential)]
  40. public struct ENetAddress
  41. {
  42. public uint host;
  43. public ushort port;
  44. }
  45. [StructLayout(LayoutKind.Sequential)]
  46. public struct ENetCallbacks
  47. {
  48. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  49. public delegate IntPtr malloc_cb(IntPtr size);
  50. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  51. public delegate void free_cb(IntPtr memory);
  52. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  53. public delegate void no_memory_cb();
  54. public IntPtr malloc, free, no_memory;
  55. }
  56. [StructLayout(LayoutKind.Sequential)]
  57. public struct ENetCompressor
  58. {
  59. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  60. public delegate void compress_cb(
  61. IntPtr context, IntPtr inBuffers, IntPtr inBufferCount, IntPtr inLimit, IntPtr outData, IntPtr outLimit);
  62. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  63. public delegate void decompress_cb(IntPtr context, IntPtr inData, IntPtr inLimit, IntPtr outData, IntPtr outLimit);
  64. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  65. public delegate void destroy_cb(IntPtr context);
  66. public IntPtr context;
  67. public IntPtr compress, decompress, destroy;
  68. }
  69. [StructLayout(LayoutKind.Sequential)]
  70. public struct ENetEvent
  71. {
  72. public readonly EventType type;
  73. public readonly IntPtr peer;
  74. public readonly byte channelID;
  75. public readonly uint data;
  76. public readonly IntPtr packet;
  77. }
  78. [StructLayout(LayoutKind.Sequential)]
  79. public struct ENetHost
  80. {
  81. }
  82. [StructLayout(LayoutKind.Sequential)]
  83. public class ENetListNode
  84. {
  85. public ENetListNode next;
  86. public ENetListNode previous;
  87. }
  88. [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
  89. public delegate void ENetPacketFreeCallback(ref ENetPacket param0);
  90. [StructLayoutAttribute(LayoutKind.Sequential)]
  91. public struct ENetPacket
  92. {
  93. public uint referenceCount;
  94. public uint flags;
  95. [MarshalAsAttribute(UnmanagedType.LPStr)]
  96. public StringBuilder data;
  97. public uint dataLength;
  98. public ENetPacketFreeCallback freeCallback;
  99. }
  100. [StructLayout(LayoutKind.Sequential)]
  101. public struct ENetPeer
  102. {
  103. public ENetListNode dispatchList;
  104. public readonly IntPtr host;
  105. public readonly ushort outgoingPeerID;
  106. public readonly ushort incomingPeerID;
  107. public readonly uint connectID;
  108. public readonly byte outgoingSessionID;
  109. public readonly byte incomingSessionID;
  110. public ENetAddress address;
  111. public IntPtr data;
  112. public readonly PeerState state;
  113. }
  114. }