Skip to content

Commit

Permalink
Add functions to get last send/receive time of a peer
Browse files Browse the repository at this point in the history
  • Loading branch information
nxrighthere authored Oct 17, 2018
1 parent b4060df commit 826c9d8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 4 deletions.
26 changes: 24 additions & 2 deletions Source/Managed/ENet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,22 @@ public uint RoundTripTime {
}
}

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();
Expand Down Expand Up @@ -690,7 +706,7 @@ public static class Library {
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();
Expand Down Expand Up @@ -814,6 +830,12 @@ internal static class Native {
[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);

Expand Down Expand Up @@ -856,4 +878,4 @@ internal static class Native {
[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
internal static extern void enet_peer_reset(IntPtr peer);
}
}
}
14 changes: 12 additions & 2 deletions Source/Native/enet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 *);
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 826c9d8

Please sign in to comment.