-
-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
SteamNetworkingSockets support with the new flat interface in 1.48 #341
Comments
I'm also curious to know the answer to this, as it is necessary for a project I am working on, @rlabrecque. Thanks as well for your time. |
@rlabrecque I would also like to know the answer to this as I use the project that froox and shifty are part of and I'm having issues with the current network implementation that's in place at the moment. |
Some work has started on this last weekend, should be able to get something in this weekend! |
That's fantastic to hear. Thanks for the update, @rlabrecque. |
Initial support is in as of 6700235 Note that it's likely very rough, I haven't started trying to use this yet, but it's all there now! I probably won't get a chance to actually use this for a bit, so if anyone tries it out please let me know any pain points you hit. |
Thank you so much for working on this! I have given it a try, but ran into an issue, using any of the functions throws following exception:
It seems that it doesn't like this struct: [StructLayout(LayoutKind.Explicit)]
public struct OptionValue
{
[FieldOffset(0)]
public int m_int32;
[FieldOffset(0)]
public long m_int64;
[FieldOffset(0)]
public float m_float;
[FieldOffset(0)]
public string m_string; // Points to your '\0'-terminated buffer
[FieldOffset(0)]
public IntPtr m_functionPtr;
} Particularly the string member. If I comment it out then it works fine, but it's not possible to use string based options. Using an IntPtr to explicitly marshaled string (like with Marshal.StringToHGlobalAnsi) should work there, but adds extra work on the API user. Is there a better solution to this? |
I found another issue with the wrapper, on the function ReceiveMessagesOnPollGroup and ReceiveMessagesOnConnection. They use I've changed the native method import to this: [DllImport(NativeLibraryName, EntryPoint = "SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnPollGroup", CallingConvention = CallingConvention.Cdecl)]
public static extern int ISteamNetworkingSockets_ReceiveMessagesOnPollGroup(IntPtr instancePtr, HSteamNetPollGroup hPollGroup, IntPtr[] ppOutMessages, int nMaxMessages); And updated the methods appropriately and then used Adding a method that wraps this behavior around could help. The ValveSockets project provides methods for the open source version of the networking library, which I think could be adapted: https://github.com/nxrighthere/ValveSockets-CSharp/blob/master/ValveSockets.cs#L641 EDIT: Also related issue to this, the Release() method on the SteamNetworkingMessage_t will cause crash, because it passes the managed instance of the struct, rather than the pointer to the native struct originally returned by the SteamAPI_ISteamNetworkingSockets_ReceiveMessagesOnPollGroup I've modified the method to this: [DllImport(NativeLibraryName, EntryPoint = "SteamAPI_SteamNetworkingMessage_t_Release", CallingConvention = CallingConvention.Cdecl)]
public static extern void SteamAPI_SteamNetworkingMessage_t_Release(IntPtr ptr); And just pass the pointers from the returned IntPtr[] array, but it probably needs a cleaner solution for the library itself. Other than that, so far it seems to work! I'm sending data back and forth! :D |
Thanks for having a look dude! Sorry I didn't get to test it out that much!
Hmm yeah that is definitely supposed to be an IntPtr Maybe IntPtr with a Getter/Setter like we're looking at in #347 ? |
Thank you so much! And no worries, you did pretty much the brunt of it which helped a lot, I'm happy to help test it out. There's one more thing that I had to modify on my end. The This works, I just had to make the member public rather than internal, so in my code I can assign the pointer returned from It might be worth to wrap this behavior around later to simplify the API for users, but it works without it! I got the Steam Networking Sockets fully integrated with my project and so far it all works correctly, so it should be good! I haven't used all pieces of the API though, but the main ones seem good. Thanks again for working on this! |
Oh I understand now, yeah I was following their pattern for https://github.com/nxrighthere/ValveSockets-CSharp/blob/master/ValveSockets.cs#L653 |
Hello!
I'd like to ask if the SteamNetworkingSockets API is planned to be included as part of Steamworks.NET, with the addition of the flat C interface in the version 1.48 (ValveSoftware/GameNetworkingSockets#70).
The topic mentions that Valve is working with you on the implementation, so I wanted to ask if that's indeed coming and if there's any rough ETA.
Thank you for your time!
The text was updated successfully, but these errors were encountered: