Skip to content

Commit

Permalink
SteamNetworkingMessage_t: Implement a Release function which takes an…
Browse files Browse the repository at this point in the history
… IntPtr
  • Loading branch information
rlabrecque committed Jun 5, 2021
1 parent 9416761 commit 1f60545
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 @@ -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 1f60545

Please # to comment.