|
|
@@ -6,100 +6,104 @@ namespace Base
|
|
|
{
|
|
|
public static class NativeMethods
|
|
|
{
|
|
|
+#if UNITY_IOS && !UNITY_EDITOR
|
|
|
+ private const string LIB = "__Internal";
|
|
|
+#else
|
|
|
private const string LIB = "ENet";
|
|
|
+#endif
|
|
|
|
|
|
public const int ENET_PROTOCOL_MAXIMUM_CHANNEL_COUNT = 255;
|
|
|
public const int ENET_PROTOCOL_MAXIMUM_PEER_ID = 0xfff;
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_address_set_host", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetAddressSetHost(ref ENetAddress address, string hostName);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_address_set_host(ref ENetAddress address, string hostName);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_address_get_host", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetAddressGetHost(ref ENetAddress address, StringBuilder hostName, uint nameLength);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_address_get_host(ref ENetAddress address, StringBuilder hostName, uint nameLength);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_address_get_host_ip", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetAddressGetHostIp(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_address_get_host_ip(ref ENetAddress address, StringBuilder hostIp, uint ipLength);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_deinitialize", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetDeinitialize();
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_deinitialize();
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_initialize", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetInitialize();
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_initialize();
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_create", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern IntPtr ENetHostCreate(
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern IntPtr enet_host_create(
|
|
|
ref ENetAddress address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_create", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern IntPtr ENetHostCreate(IntPtr address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern IntPtr enet_host_create(IntPtr address, uint peerLimit, uint channelLimit, uint incomingBandwidth, uint outgoingBandwidth);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_destroy", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetHostDestroy(IntPtr host);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_host_destroy(IntPtr host);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_connect", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern IntPtr ENetHostConnect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern IntPtr enet_host_connect(IntPtr host, ref ENetAddress address, uint channelCount, uint data);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_broadcast", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetHostBroadcast(IntPtr host, byte channelID, IntPtr packet);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_host_broadcast(IntPtr host, byte channelID, IntPtr packet);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_compress", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetHostCompress(IntPtr host, IntPtr compressor);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_host_compress(IntPtr host, IntPtr compressor);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_compress_with_range_coder", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetHostCompressWithRangeCoder(IntPtr host);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_host_compress_with_range_coder(IntPtr host);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_channel_limit", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetHostChannelLimit(IntPtr host, uint channelLimit);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_host_channel_limit(IntPtr host, uint channelLimit);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_bandwidth_limit", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetHostBandwidthLimit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_host_bandwidth_limit(IntPtr host, uint incomingBandwidth, uint outgoingBandwidth);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_flush", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetHostFlush(IntPtr host);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_host_flush(IntPtr host);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_check_events", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetHostCheckEvents(IntPtr host, ENetEvent ev);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_host_check_events(IntPtr host, ref ENetEvent ev);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_host_service", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetHostService(IntPtr host, ENetEvent ev, uint timeout);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_host_service(IntPtr host, IntPtr ev, uint timeout);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_time_get", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern uint ENetTimeGet();
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern uint enet_time_get();
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_time_set", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetTimeSet(uint newTimeBase);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_time_set(uint newTimeBase);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_packet_create", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern IntPtr ENetPacketCreate(byte[] data, uint dataLength, PacketFlags flags);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern IntPtr enet_packet_create(byte[] data, uint dataLength, PacketFlags flags);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_packet_destroy", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetPacketDestroy(IntPtr packet);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_packet_destroy(IntPtr packet);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_packet_resize", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetPacketResize(IntPtr packet, uint dataLength);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_packet_resize(IntPtr packet, uint dataLength);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_peer_throttle_configure", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetPeerThrottleConfigure(IntPtr peer, uint interval, uint acceleration, uint deceleration);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_peer_throttle_configure(IntPtr peer, uint interval, uint acceleration, uint deceleration);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_peer_send", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern int ENetPeerSend(IntPtr peer, byte channelID, IntPtr packet);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern int enet_peer_send(IntPtr peer, byte channelID, IntPtr packet);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_peer_receive", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern IntPtr ENetPeerReceive(IntPtr peer, out byte channelID);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern IntPtr enet_peer_receive(IntPtr peer, out byte channelID);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_peer_reset", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetPeerReset(IntPtr peer);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_peer_reset(IntPtr peer);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_peer_ping", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetPeerPing(IntPtr peer);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_peer_ping(IntPtr peer);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_peer_disconnect_now", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetPeerDisconnectNow(IntPtr peer, uint data);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_peer_disconnect_now(IntPtr peer, uint data);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_peer_disconnect", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetPeerDisconnect(IntPtr peer, uint data);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_peer_disconnect(IntPtr peer, uint data);
|
|
|
|
|
|
- [DllImport(LIB, EntryPoint = "enet_peer_disconnect_later", CallingConvention = CallingConvention.Cdecl)]
|
|
|
- internal static extern void ENetPeerDisconnectLater(IntPtr peer, uint data);
|
|
|
+ [DllImport(LIB)]
|
|
|
+ internal static extern void enet_peer_disconnect_later(IntPtr peer, uint data);
|
|
|
}
|
|
|
}
|