feat(gdk): expose the XNetworking API surface as GDK.networking - #157
Conversation
Adds a new `GDK.networking` service (`XboxNetworking`) wrapping the Microsoft GDK `XNetworking.h` family: the preferred local UDP multiplayer port (sync, async, and change signal), device connectivity hints (query + change signal), NSAL certificate information for title endpoints, and the TCP queued-receive buffer configuration/statistics surfaces. `XboxNetworkingSecurityInformation` is a new RefCounted wrapper that owns the native result buffer for its lifetime, because the native record's thumbprint pointers point into it. Two entry points are deliberately not wrapped, and the spec/docs say why: `XNetworkingVerifyServerCertificate` requires a WinHTTP HINTERNET handle Godot does not expose, and the Utf16 security-information variant differs only in input encoding, which Godot's single String type cannot express. The configuration/statistics methods are documented no-ops on Windows. They are wrapped anyway so the surface is identical on console-capable Godot forks. Also updates spec/gdext-gdk.md (scope table, service section with native API mapping, and the two stale "do not wrap XNetworking" lists), spec/gdext-csharp.md, docs/gdk/api-reference.md, docs/gdk/plugin.md, docs/gdk/async-system.md, docs/gdk/native-runtime.md, docs/README.md, the C# facade, and adds GUT coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f04a7dcf-127c-4e73-adea-f19c823ab5fa
There was a problem hiding this comment.
Pull request overview
Adds a new GDK.networking service (XboxNetworking) to the godot_gdk addon to expose the script-facing Microsoft GDK XNetworking.h diagnostics/configuration surface (ports, connectivity hints, NSAL security info, TCP queued-receive-buffer settings/stats), plus C# facade parity and supporting docs/tests.
Changes:
- Introduces
XboxNetworking+XboxNetworkingSecurityInformation(C++ bindings, registration, singleton wiring, doc_classes). - Adds GUT coverage for the new service and updates specs/docs to document the new surface and deliberate exclusions.
- Adds C# service/type wrappers (
Xbox.Networking) and updates C# mapping spec.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/godot/gdk/tests/test_networking.gd | New GUT suite covering GDK.networking surface, validation, and payload shapes. |
| spec/gdext-gdk.md | Adds GDK.networking to scope table and spec section with API mapping/notes. |
| spec/gdext-csharp.md | Documents C# parity mapping for Xbox.Networking. |
| docs/README.md | Adds GDK.networking to top-level docs service list. |
| docs/gdk/plugin.md | Mentions networking service in plugin overview and service enumeration. |
| docs/gdk/native-runtime.md | Updates runtime structure/service lists to include GDK.networking. |
| docs/gdk/async-system.md | Updates async system docs to include GDK.networking and new implementation files. |
| docs/gdk/api-reference.md | Adds full API reference section for GDK.networking including payload details. |
| addons/godot_gdk/src/xbox.h | Adds XboxNetworking forward decl, member, and getter. |
| addons/godot_gdk/src/xbox.cpp | Instantiates the service, binds it, exposes property, and wires init/shutdown steps. |
| addons/godot_gdk/src/xbox_networking.h | New C++ service + NSAL wrapper type declarations and Godot bindings. |
| addons/godot_gdk/src/xbox_networking.cpp | New implementation of XNetworking wrappers, signal registration, and payload shaping. |
| addons/godot_gdk/src/register_types.cpp | Registers the new classes with Godot. |
| addons/godot_gdk/doc_classes/XboxNetworkingSecurityInformation.xml | New class reference docs for NSAL result wrapper. |
| addons/godot_gdk/doc_classes/XboxNetworking.xml | New class reference docs for XboxNetworking service. |
| addons/godot_gdk/doc_classes/Xbox.xml | Documents the new get_networking() and networking member on the root singleton. |
| addons/godot_gdk/CMakeLists.txt | Adds xbox_networking.cpp to the addon build. |
| addons/godot_gdk_csharp/Xbox.cs | Adds Xbox.Networking static service accessor + reset wiring. |
| addons/godot_gdk_csharp/Types/XboxNetworkingSecurityInformation.cs | New C# wrapper type for the NSAL security info object. |
| addons/godot_gdk_csharp/Services/XboxNetworking.cs | New C# service wrapper with events and methods matching the GDScript surface. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Include <cstring> and <limits> in xbox_networking.cpp. memcpy() was relying on a transitive include; every other addon source that calls it includes <cstring> explicitly. - Replace unchecked static_cast<int64_t>(uint64_t) with the to_variant_u64() clamping helper already used by xbox_package.cpp. The raw cast is only well-defined from C++20 on, and any out-of-range value silently wrapped negative, contradicting the documented payload. Applied to both query_configuration_setting() and the query_statistics() byte counters, which had the same unchecked conversion. - Correct the stale "21 public service namespaces" count in native-runtime.md now that the enumerated list has 22. - Sync the clamping contract into XboxNetworking.xml, docs/gdk/api-reference.md, and spec/gdext-gdk.md, and state that `unlimited` (not a -1 test) is the authoritative flag. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f04a7dcf-127c-4e73-adea-f19c823ab5fa
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
addons/godot_gdk/src/xbox_networking.cpp:219
QuerySecurityInformationAsyncContext::finalize()passesbuffer_sizeintoXboxNetworkingSecurityInformation::set_native_internal(...), but the GDK also returnsbytes_used(the actual bytes written). Storing the requested size instead of the used size can makem_buffer_sizeinaccurate for future native-interop use and makes it harder to validate the buffer contents.
Ref<XboxNetworkingSecurityInformation> info;
info.instantiate();
info->set_native_internal(std::move(buffer), buffer_size, native);
get_pending_signal()->complete(XboxResult::ok_result(info));
| The current native implementation has one root singleton and 22 public service namespaces: | ||
|
|
||
| - root singleton: `GDK` | ||
| - service namespaces: `GDK.users`, `GDK.game_ui`, `GDK.accessibility`, `GDK.achievements`, `GDK.package`, `GDK.stats`, `GDK.leaderboards`, `GDK.privacy`, `GDK.presence`, `GDK.social`, `GDK.store`, `GDK.profile`, `GDK.string_verify`, `GDK.title_storage`, `GDK.error_reporting`, `GDK.launcher`, `GDK.multiplayer_activity`, `GDK.capture`, `GDK.system`, `GDK.display`, and `GDK.activation` | ||
| - wrapper types: `XboxResult`, `XboxUsers`, `XboxUser`, `XboxGameUI`, `XboxAccessibility`, `XboxClosedCaptionProperties`, `XboxAchievements`, `XboxAchievement`, `XboxPackage`, `XboxPackageMount`, `XboxPackageResourcePack`, `XboxStats`, `XboxLeaderboards`, `XboxLeaderboard`, `XboxLeaderboardColumn`, `XboxLeaderboardRow`, `XboxPrivacy`, `XboxPresence`, `XboxPresenceRecord`, `XboxSocial`, `XboxSocialFilter`, `XboxSocialGroup`, `XboxSocialUser`, `XboxStore`, `XboxStoreLicenseStatus`, `XboxProfile`, `XboxUserProfile`, `XboxStringVerify`, `XboxTitleStorage`, `XboxTitleStorageBlobMetadata`, `XboxTitleStorageBlobMetadataResult`, `XboxErrorReporting`, `XboxLauncher`, `XboxMultiplayerActivity`, `XboxMultiplayerActivityInfo`, `XboxCapture`, `XboxCaptureMetaData`, `XboxSystem`, `XboxDisplay`, `XboxDisplayTimeoutDeferral`, and `XboxActivation` | ||
| - service namespaces: `GDK.users`, `GDK.game_ui`, `GDK.accessibility`, `GDK.achievements`, `GDK.package`, `GDK.stats`, `GDK.leaderboards`, `GDK.privacy`, `GDK.presence`, `GDK.social`, `GDK.store`, `GDK.profile`, `GDK.string_verify`, `GDK.title_storage`, `GDK.error_reporting`, `GDK.launcher`, `GDK.multiplayer_activity`, `GDK.capture`, `GDK.system`, `GDK.display`, `GDK.activation`, and `GDK.networking` | ||
| - wrapper types: `XboxResult`, `XboxUsers`, `XboxUser`, `XboxGameUI`, `XboxAccessibility`, `XboxClosedCaptionProperties`, `XboxAchievements`, `XboxAchievement`, `XboxPackage`, `XboxPackageMount`, `XboxPackageResourcePack`, `XboxStats`, `XboxLeaderboards`, `XboxLeaderboard`, `XboxLeaderboardColumn`, `XboxLeaderboardRow`, `XboxPrivacy`, `XboxPresence`, `XboxPresenceRecord`, `XboxSocial`, `XboxSocialFilter`, `XboxSocialGroup`, `XboxSocialUser`, `XboxStore`, `XboxStoreLicenseStatus`, `XboxProfile`, `XboxUserProfile`, `XboxStringVerify`, `XboxTitleStorage`, `XboxTitleStorageBlobMetadata`, `XboxTitleStorageBlobMetadataResult`, `XboxErrorReporting`, `XboxLauncher`, `XboxMultiplayerActivity`, `XboxMultiplayerActivityInfo`, `XboxCapture`, `XboxCaptureMetaData`, `XboxSystem`, `XboxDisplay`, `XboxDisplayTimeoutDeferral`, `XboxActivation`, `XboxNetworking`, and `XboxNetworkingSecurityInformation` |
There was a problem hiding this comment.
Fixed in d96a9a0 — updated the remaining reference to 22 public namespaces.
Co-authored-by: jameslen-atg <24258495+jameslen-atg@users.noreply.github.com>
Adds a new
GDK.networkingservice (XboxNetworking) that exposes the full Microsoft GDKXNetworking.hsurface, following the established one-service-namespace-under-the-GDK-singleton pattern.What's exposed
query_preferred_local_udp_multiplayer_port()XNetworkingQueryPreferredLocalUdpMultiplayerPortquery_preferred_local_udp_multiplayer_port_async()XNetworkingQueryPreferredLocalUdpMultiplayerPortAsync(+Result)get_connectivity_hint()XNetworkingGetConnectivityHintquery_security_information_for_url_async(url)XNetworkingQuerySecurityInformationForUrlAsync(+ResultSize/Result)query_configuration_setting(setting)XNetworkingQueryConfigurationSettingset_configuration_setting(setting, value)XNetworkingSetConfigurationSettingquery_statistics(statistics_type)XNetworkingQueryStatisticspreferred_local_udp_multiplayer_port_changedsignalXNetworkingRegister/UnregisterPreferredLocalUdpMultiplayerPortChangedconnectivity_hint_changedsignalXNetworkingRegister/UnregisterConnectivityHintChangedPlus a new
XboxNetworkingSecurityInformationRefCounted wrapper for NSAL results.Usage
C# facade parity (
Xbox.Networking) ships in the same change:Deliberate exclusions
Both are documented in
spec/gdext-gdk.mdanddocs/gdk/api-reference.mdrather than silently dropped:XNetworkingVerifyServerCertificate— itsrequestHandleis a WinHTTPHINTERNETproduced byWinHttpOpenRequest, and it is meant to be called from inside aWINHTTP_CALLBACK_STATUS_SENDING_REQUESTcallback. Godot'sHTTPClient/HTTPRequestexpose no such handle, so it cannot be called correctly from GDScript.XboxNetworkingSecurityInformationintentionally retains the native result buffer so a native-interop entry point can be added later without a breaking change.XNetworkingQuerySecurityInformationForUrlUtf16Async— differs from the UTF-8 entry point only in input encoding, which is not observable through Godot's singleStringtype.Behavior notes
GDK.initialize()on the shared task queue and torn down on shutdown. The GDK fires an initial callback on registration, so the first emission of each signal reports current state rather than a change. Registration failure degrades with a warning (signals disabled, queries still work) instead of failingGDK.initialize()— same graceful-degradation posture asGDK.activation.query_configuration_setting,set_configuration_setting, andquery_statisticsare documented Windows no-ops (setter returnsE_NOTIMPL, surfaced as thenot_supported_on_platformcode; queries return zeros). Wrapped anyway so the surface is identical on console-capable Godot forks.uint64configuration values do not round-trip through GDScript's signedint, soquery_configuration_settingreports a companionunlimited: boolfor theUINT64_MAXcase.GDK.game_chatrule that titles own their own networking.Docs and spec
spec/gdext-gdk.md— new scope-table row, aGDK.networkingservice section with a native API mapping table, and reconciliation of the two stale "do not wrapXNetworking" lists that predate this change.spec/gdext-csharp.md,docs/gdk/api-reference.md,docs/gdk/plugin.md,docs/gdk/async-system.md,docs/gdk/native-runtime.md,docs/README.md— service enumerations and the full reference section.No sample content was added: the connectivity/NSAL surfaces have no meaningful offline demo, and the tutorial tracks are being reworked separately.
Validation
tools\check_gd_scripts_headless.ps1— pass.tools\run_all_tests.ps1— pass (offline tier). GDK host went 330 → 336 tests, 3094 → 3209 asserts, 0 failed; PlayFab and GameInput hosts unchanged and green; C++ doctest and all bootstrap mini-runners green.tools\run_csharp_tests.ps1— 109 passed, 0 failed (was 107; +2 for the two newdoc_classes).tests/godot/gdk/tests/test_networking.gd— 6/6 passing, 115 asserts, no pendings on a machine with the GDK runtime available.-Live, no-AllowLiveWrites). Nothing in this change writes online state.