Skip to content

Commit

Permalink
Merge pull request #425 from rlabrecque/steamnetworkingmessage-release
Browse files Browse the repository at this point in the history
SteamNetworkingMessage_t improvements
  • Loading branch information
rlabrecque authored Jun 6, 2021
2 parents 9416761 + 353de9d commit 42aebda
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public struct SteamNetworkingMessage_t
/// usually be something like:
///
/// free( pMsg->m_pData );
internal IntPtr m_pfnFreeData;
public IntPtr m_pfnFreeData;

/// Function to used to decrement the internal reference count and, if
/// it's zero, release the message. You should not set this function pointer,
Expand All @@ -79,7 +79,20 @@ public struct SteamNetworkingMessage_t
/// You MUST call this when you're done with the object,
/// to free up memory, etc.
public void Release() {
NativeMethods.SteamAPI_SteamNetworkingMessage_t_Release(m_pfnRelease);
throw new System.NotImplementedException("Please use the static Release function instead which takes an IntPtr.");
}

/// You MUST call this when you're done with the object,
/// to free up memory, etc.
/// This is a Steamworks.NET extension.
public static void Release(IntPtr pointer) {
NativeMethods.SteamAPI_SteamNetworkingMessage_t_Release(pointer);
}

/// Convert an IntPtr received from ISteamNetworkingSockets.ReceiveMessagesOnPollGroup into our structure.
/// This is a Steamworks.NET extension.
public static SteamNetworkingMessage_t FromIntPtr(IntPtr pointer) {
return (SteamNetworkingMessage_t)Marshal.PtrToStructure(pointer, typeof(SteamNetworkingMessage_t));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public struct SteamNetworkingMessage_t
/// usually be something like:
///
/// free( pMsg->m_pData );
internal IntPtr m_pfnFreeData;
public IntPtr m_pfnFreeData;

/// Function to used to decrement the internal reference count and, if
/// it's zero, release the message. You should not set this function pointer,
Expand All @@ -95,7 +95,20 @@ public struct SteamNetworkingMessage_t
/// You MUST call this when you're done with the object,
/// to free up memory, etc.
public void Release() {
NativeMethods.SteamAPI_SteamNetworkingMessage_t_Release(m_pfnRelease);
throw new System.NotImplementedException("Please use the static Release function instead which takes an IntPtr.");
}

/// You MUST call this when you're done with the object,
/// to free up memory, etc.
/// This is a Steamworks.NET extension.
public static void Release(IntPtr pointer) {
NativeMethods.SteamAPI_SteamNetworkingMessage_t_Release(pointer);
}

/// Convert an IntPtr received from ISteamNetworkingSockets.ReceiveMessagesOnPollGroup into our structure.
/// This is a Steamworks.NET extension.
public static SteamNetworkingMessage_t FromIntPtr(IntPtr pointer) {
return (SteamNetworkingMessage_t)Marshal.PtrToStructure(pointer, typeof(SteamNetworkingMessage_t));
}
}
}
Expand Down

0 comments on commit 42aebda

Please # to comment.