Browse Source

Added PeerID fetching.

Added PeerID fetching.
Maxim 6 years ago
parent
commit
3b804f7c77
1 changed files with 12 additions and 1 deletions
  1. 12 1
      Source/Managed/ENet.cs

+ 12 - 1
Source/Managed/ENet.cs

@@ -607,6 +607,7 @@ namespace ENet {
 	public struct Peer {
 		private IntPtr nativePeer;
 		private uint nativeID;
+		private ushort nativePeerID;
 
 		internal IntPtr NativeData {
 			get {
@@ -621,6 +622,7 @@ namespace ENet {
 		public Peer(IntPtr peer) {
 			nativePeer = peer;
 			nativeID = nativePeer != IntPtr.Zero ? Native.enet_peer_get_id(nativePeer) : 0;
+			nativePeerID = nativePeer != IntPtr.Zero ? Native.enet_peer_get_peer_id(nativePeer) : 0;
 		}
 
 		public bool IsSet {
@@ -634,6 +636,12 @@ namespace ENet {
 				return nativeID;
 			}
 		}
+		
+		public ushort PeerID {
+			get {
+				return nativePeerID;
+			}
+		}
 
 		public string IP {
 			get {
@@ -963,6 +971,9 @@ namespace ENet {
 
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern uint enet_peer_get_id(IntPtr peer);
+		
+		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
+		internal static extern ushort enet_peer_get_peer_id(IntPtr peer);
 
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern int enet_peer_get_ip(IntPtr peer, byte[] ip, IntPtr ipLength);
@@ -1027,4 +1038,4 @@ namespace ENet {
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern void enet_peer_reset(IntPtr peer);
 	}
-}
+}