Native.Structs.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #region License
  2. /*
  3. ENet for C#
  4. Copyright (c) 2011 James F. Bellinger <jfb@zer7.com>
  5. Permission to use, copy, modify, and/or distribute this software for any
  6. purpose with or without fee is hereby granted, provided that the above
  7. copyright notice and this permission notice appear in all copies.
  8. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #endregion
  17. using System;
  18. using System.Runtime.InteropServices;
  19. namespace ENet
  20. {
  21. public static unsafe partial class Native
  22. {
  23. [StructLayout(LayoutKind.Sequential)]
  24. public struct ENetAddress
  25. {
  26. public uint host;
  27. public ushort port;
  28. }
  29. [StructLayout(LayoutKind.Sequential)]
  30. public struct ENetCallbacks
  31. {
  32. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  33. public delegate IntPtr malloc_cb(IntPtr size);
  34. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  35. public delegate void free_cb(IntPtr memory);
  36. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  37. public delegate void no_memory_cb();
  38. public IntPtr malloc, free, no_memory;
  39. }
  40. [StructLayout(LayoutKind.Sequential)]
  41. public struct ENetCompressor
  42. {
  43. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  44. public delegate void compress_cb(
  45. IntPtr context, IntPtr inBuffers, IntPtr inBufferCount, IntPtr inLimit, IntPtr outData, IntPtr outLimit);
  46. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  47. public delegate void decompress_cb(IntPtr context, IntPtr inData, IntPtr inLimit, IntPtr outData, IntPtr outLimit);
  48. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  49. public delegate void destroy_cb(IntPtr context);
  50. public IntPtr context;
  51. public IntPtr compress, decompress, destroy;
  52. }
  53. [StructLayout(LayoutKind.Sequential)]
  54. public struct ENetEvent
  55. {
  56. public readonly EventType type;
  57. public readonly ENetPeer* peer;
  58. public readonly byte channelID;
  59. public readonly uint data;
  60. public readonly ENetPacket* packet;
  61. }
  62. [StructLayout(LayoutKind.Sequential)]
  63. public struct ENetHost
  64. {
  65. }
  66. [StructLayout(LayoutKind.Sequential)]
  67. public struct ENetListNode
  68. {
  69. public readonly ENetListNode* next;
  70. public readonly ENetListNode* previous;
  71. }
  72. [StructLayout(LayoutKind.Sequential)]
  73. public struct ENetPacket
  74. {
  75. [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
  76. public delegate void freeCallback_cb(IntPtr packet);
  77. public IntPtr referenceCount;
  78. public readonly PacketFlags flags;
  79. public readonly void* data;
  80. public IntPtr dataLength;
  81. public IntPtr freeCallback;
  82. }
  83. [StructLayout(LayoutKind.Sequential)]
  84. public struct ENetPeer
  85. {
  86. public ENetListNode dispatchList;
  87. public readonly ENetHost* host;
  88. public readonly ushort outgoingPeerID;
  89. public readonly ushort incomingPeerID;
  90. public readonly uint connectID;
  91. public readonly byte outgoingSessionID;
  92. public readonly byte incomingSessionID;
  93. public ENetAddress address;
  94. public IntPtr data;
  95. public readonly PeerState state;
  96. }
  97. }
  98. }