Browse Source

Add functions to get last send/receive time of a peer

NX 7 years ago
parent
commit
826c9d87e2
2 changed files with 36 additions and 4 deletions
  1. 24 2
      Source/Managed/ENet.cs
  2. 12 2
      Source/Native/enet.h

+ 24 - 2
Source/Managed/ENet.cs

@@ -574,6 +574,22 @@ namespace ENet {
 			}
 		}
 
+		public uint LastSendTime {
+			get {
+				CheckCreated();
+
+				return Native.enet_peer_get_lastsendtime(nativePeer);
+			}
+		}
+
+		public uint LastReceiveTime {
+			get {
+				CheckCreated();
+
+				return Native.enet_peer_get_lastreceivetime(nativePeer);
+			}
+		}
+
 		public ulong PacketsSent {
 			get {
 				CheckCreated();
@@ -690,7 +706,7 @@ namespace ENet {
 		public const uint timeoutLimit = 32;
 		public const uint timeoutMinimum = 5000;
 		public const uint timeoutMaximum = 30000;
-		public const uint version = (2 << 16) | (0 << 8) | (9);
+		public const uint version = (2 << 16) | (1 << 8) | (0);
 
 		public static int Initialize() {
 			return Native.enet_initialize();
@@ -814,6 +830,12 @@ namespace ENet {
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern uint enet_peer_get_rtt(IntPtr peer);
 
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_peer_get_lastsendtime(IntPtr peer);
+
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern uint enet_peer_get_lastreceivetime(IntPtr peer);
+
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern ulong enet_peer_get_packets_sent(IntPtr peer);
 
@@ -856,4 +878,4 @@ namespace ENet {
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern void enet_peer_reset(IntPtr peer);
 	}
-}
+}

+ 12 - 2
Source/Native/enet.h

@@ -30,8 +30,8 @@
 #include <time.h>
 
 #define ENET_VERSION_MAJOR 2
-#define ENET_VERSION_MINOR 0
-#define ENET_VERSION_PATCH 9
+#define ENET_VERSION_MINOR 1
+#define ENET_VERSION_PATCH 0
 #define ENET_VERSION_CREATE(major, minor, patch) (((major)<<16) | ((minor)<<8) | (patch))
 #define ENET_VERSION_GET_MAJOR(version) (((version)>>16)&0xFF)
 #define ENET_VERSION_GET_MINOR(version) (((version)>>8)&0xFF)
@@ -784,6 +784,8 @@ extern "C" {
     ENET_API enet_uint16         enet_peer_get_port (ENetPeer *);
     ENET_API ENetPeerState       enet_peer_get_state (ENetPeer *);
     ENET_API enet_uint32         enet_peer_get_rtt (ENetPeer *);
+    ENET_API enet_uint32         enet_peer_get_lastsendtime (ENetPeer *);
+    ENET_API enet_uint32         enet_peer_get_lastreceivetime (ENetPeer *);
     ENET_API enet_uint64         enet_peer_get_packets_sent (ENetPeer *);
     ENET_API enet_uint32         enet_peer_get_packets_lost (ENetPeer *);
     ENET_API enet_uint64         enet_peer_get_bytes_sent (ENetPeer *);
@@ -4456,6 +4458,14 @@ extern "C" {
         return peer->roundTripTime;
     }
 
+    enet_uint32 enet_peer_get_lastsendtime(ENetPeer *peer) {
+        return peer->lastSendTime;
+    }
+
+    enet_uint32 enet_peer_get_lastreceivetime(ENetPeer *peer) {
+        return peer->lastReceiveTime;
+    }
+
     enet_uint64 enet_peer_get_packets_sent(ENetPeer *peer) {
         return peer->totalPacketsSent;
     }