Browse Source

Add address parameter to the intercept callback

nxrighthere 5 years ago
parent
commit
8e1c2fb515
3 changed files with 7 additions and 7 deletions
  1. 1 1
      README.md
  2. 3 3
      Source/Managed/ENet.cs
  3. 3 3
      Source/Native/enet.h

+ 1 - 1
README.md

@@ -280,7 +280,7 @@ Provides per packet events.
 #### Host callbacks
 #### Host callbacks
 Provides per host events.
 Provides per host events.
 
 
-`InterceptCallback(ref Event @event, IntPtr receivedData, int receivedDataLength)` notifies when a raw UDP packet is intercepted. Status code returned from this callback instructs ENet how the set event should be handled. Returning 1 indicates dispatching of the set event by the service. Returning 0 indicates that ENet subsystems should handle received data. Returning -1 indicates an error. A reference to the delegate should be preserved from being garbage collected.
+`InterceptCallback(ref Event @event, ref Address address, IntPtr receivedData, int receivedDataLength)` notifies when a raw UDP packet is intercepted. Status code returned from this callback instructs ENet how the set event should be handled. Returning 1 indicates dispatching of the set event by the service. Returning 0 indicates that ENet subsystems should handle received data. Returning -1 indicates an error. A reference to the delegate should be preserved from being garbage collected.
 
 
 `ChecksumCallback(IntPtr buffers, int bufferCount)` notifies when a checksum should be computed for buffers at sending and receiving. A value returned from this callback is a 64-bit checksum. ENet automatically handles integrity verification of packets if a checksum mechanism is enabled at both ends. Can be used with `ENet.Library.CRC64()` function. A reference to the delegate should be preserved from being garbage collected.
 `ChecksumCallback(IntPtr buffers, int bufferCount)` notifies when a checksum should be computed for buffers at sending and receiving. A value returned from this callback is a 64-bit checksum. ENet automatically handles integrity verification of packets if a checksum mechanism is enabled at both ends. Can be used with `ENet.Library.CRC64()` function. A reference to the delegate should be preserved from being garbage collected.
 
 

+ 3 - 3
Source/Managed/ENet.cs

@@ -89,7 +89,7 @@ namespace ENet {
 	public delegate void FreeCallback(IntPtr memory);
 	public delegate void FreeCallback(IntPtr memory);
 	public delegate void NoMemoryCallback();
 	public delegate void NoMemoryCallback();
 	public delegate void PacketFreeCallback(Packet packet);
 	public delegate void PacketFreeCallback(Packet packet);
-	public delegate int InterceptCallback(ref Event @event, IntPtr receivedData, int receivedDataLength);
+	public delegate int InterceptCallback(ref Event @event, ref Address address, IntPtr receivedData, int receivedDataLength);
 	public delegate ulong ChecksumCallback(IntPtr buffers, int bufferCount);
 	public delegate ulong ChecksumCallback(IntPtr buffers, int bufferCount);
 
 
 	internal static class ArrayPool {
 	internal static class ArrayPool {
@@ -941,7 +941,7 @@ namespace ENet {
 		public const uint timeoutLimit = 32;
 		public const uint timeoutLimit = 32;
 		public const uint timeoutMinimum = 5000;
 		public const uint timeoutMinimum = 5000;
 		public const uint timeoutMaximum = 30000;
 		public const uint timeoutMaximum = 30000;
-		public const uint version = (2 << 16) | (4 << 8) | (3);
+		public const uint version = (2 << 16) | (4 << 8) | (4);
 
 
 		public static uint Time {
 		public static uint Time {
 			get {
 			get {
@@ -1189,4 +1189,4 @@ namespace ENet {
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		[DllImport(nativeLibrary, CallingConvention = CallingConvention.Cdecl)]
 		internal static extern void enet_peer_reset(IntPtr peer);
 		internal static extern void enet_peer_reset(IntPtr peer);
 	}
 	}
-}
+}

+ 3 - 3
Source/Native/enet.h

@@ -31,7 +31,7 @@
 
 
 #define ENET_VERSION_MAJOR 2
 #define ENET_VERSION_MAJOR 2
 #define ENET_VERSION_MINOR 4
 #define ENET_VERSION_MINOR 4
-#define ENET_VERSION_PATCH 3
+#define ENET_VERSION_PATCH 4
 #define ENET_VERSION_CREATE(major, minor, patch) (((major) << 16) | ((minor) << 8) | (patch))
 #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_MAJOR(version) (((version) >> 16) & 0xFF)
 #define ENET_VERSION_GET_MINOR(version) (((version) >> 8) & 0xFF)
 #define ENET_VERSION_GET_MINOR(version) (((version) >> 8) & 0xFF)
@@ -629,7 +629,7 @@ extern "C" {
 
 
 	typedef uint64_t (ENET_CALLBACK *ENetChecksumCallback)(const ENetBuffer* buffers, int bufferCount);
 	typedef uint64_t (ENET_CALLBACK *ENetChecksumCallback)(const ENetBuffer* buffers, int bufferCount);
 
 
-	typedef int (ENET_CALLBACK *ENetInterceptCallback)(ENetEvent* event, uint8_t* receivedData, int receivedDataLength);
+	typedef int (ENET_CALLBACK *ENetInterceptCallback)(ENetEvent* event, ENetAddress* address, uint8_t* receivedData, int receivedDataLength);
 
 
 	typedef struct _ENetHost {
 	typedef struct _ENetHost {
 		ENetSocket socket;
 		ENetSocket socket;
@@ -2562,7 +2562,7 @@ extern "C" {
 			host->totalReceivedPackets++;
 			host->totalReceivedPackets++;
 
 
 			if (host->interceptCallback != NULL) {
 			if (host->interceptCallback != NULL) {
-				switch (host->interceptCallback(event, host->receivedData, host->receivedDataLength)) {
+				switch (host->interceptCallback(event, &host->receivedAddress, host->receivedData, host->receivedDataLength)) {
 					case 1:
 					case 1:
 						if (event != NULL && event->type != ENET_EVENT_TYPE_NONE)
 						if (event != NULL && event->type != ENET_EVENT_TYPE_NONE)
 							return 1;
 							return 1;