Skip to content

Add experimental Godot Engine GSDK#198

Open
Copilot wants to merge 8 commits intomainfrom
copilot/add-gsdk-for-godot
Open

Add experimental Godot Engine GSDK#198
Copilot wants to merge 8 commits intomainfrom
copilot/add-gsdk-for-godot

Conversation

Copy link
Contributor

Copilot AI commented Mar 7, 2026

What this PR does / why we need it:

Adds an experimental PlayFab GSDK for Godot Engine 4.x using GDScript, placed in experimental/godot/. Follows the same architecture as the existing Go experimental SDK and production C#/Java SDKs.

Structure (experimental/godot/addons/playfab_gsdk/):

  • types.gdPlayFabGsdkTypes class: GameState/GameOperation enums, config key constants, serialization helpers
  • internal_gsdk.gd — Heartbeat loop (1s Timer + HTTPRequest), state machine, config loading from GSDK_CONFIG_FILE
  • gsdk.gd — Public API autoload singleton
  • gsdk_logger.gd — Dual output logger (console + file)
  • plugin.cfg / playfab_gsdk_plugin.gd — Godot editor plugin, auto-registers PlayFabGSDK autoload

API surface matches the non-experimental GSDKs (C#, Java): start(), ready_for_players() (async via await), register_health_callback(), register_shutdown_callback(), register_maintenance_callback(), update_connected_players(), log_message(), get_game_server_connection_info(), get_logs_directory(), get_shared_content_directory(), get_initial_players(), get_config_settings().

# Usage
func _ready() -> void:
    PlayFabGSDK.register_health_callback(func() -> bool: return true)
    PlayFabGSDK.register_shutdown_callback(func() -> void: get_tree().quit())
    var is_active := await PlayFabGSDK.ready_for_players()

Main README update: Added an "Experimental GSDKs" section to the root README.md noting that experimental GSDKs are not officially supported by PlayFab and are provided on a best-effort basis, with links to GitHub Issues and MSFT Game Dev Discord for help.

GDScript style guide compliance: All code follows the official GDScript style guide:

  • Code order: extends## doc comment → signals → variables → methods
  • Signal naming uses past tense (transitioned_to_active)
  • All lines under 100 characters; long signatures wrapped with 2-level continuation indent
  • Spaces inside single-line dictionary literals ({ "key": value })
  • Static typing via := inference and explicit type annotations on all functions
  • Tab indentation, snake_case functions/variables, PascalCase classes, CONSTANT_CASE constants
  • Trailing commas in multi-line collections, two blank lines between functions

Unit tests (experimental/godot/tests/): 40 tests across 3 files using the GUT (Godot Unit Testing) framework:

  • test_types.gd (13 tests) — Enum serialization for all GameState/GameOperation values, unknown/empty string handling, config key constant verification
  • test_internal_gsdk.gd (20 tests) — Config map creation (all fields, missing fields, non-dict inputs), state machine transitions (Continue/Active/Terminate operations), signal emission, shutdown callback invocation, session config processing, initial players, metadata, maintenance callback deduplication, idempotent start
  • test_gsdk_logger.gd (7 tests) — Directory/file creation, log level formatting (INFO/WARN/ERROR/DEBUG), graceful handling without initialization

Tests require Godot runtime to execute (consistent with the Go SDK's approach). README includes GUT setup and run instructions.

Special notes for your reviewer:

  • Godot-native patterns: signals + await replace Go channels/goroutines for blocking ready_for_players()
  • Terminate operation emits transitioned_to_active signal to unblock ready_for_players() (mirrors Go's close(channel) behavior)
  • No CI workflow for tests — GDScript requires Godot runtime, consistent with Go SDK's test approach (requires Go runtime)
  • CodeQL does not analyze GDScript; no security concerns identified in manual review
  • mark_allocated() is intentionally excluded — it is Go GSDK-specific and requires special backend handling

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI self-assigned this Mar 7, 2026
Copilot AI and others added 2 commits March 7, 2026 22:09
Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
…on, improve README example

Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copilot AI changed the title [WIP] Add GSDK for Godot game engine Add experimental Godot Engine GSDK Mar 7, 2026
@dgkanatsios
Copy link
Contributor

@copilot remove the mark_allocated, this is only for the Go GSDK and requires special handling on the backend. Make sure the Godot public SDK surface is the same as the non-experimental GSDKs.

Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 7, 2026

@copilot remove the mark_allocated, this is only for the Go GSDK and requires special handling on the backend. Make sure the Godot public SDK surface is the same as the non-experimenta...

Removed mark_allocated() from gsdk.gd and all references from README.md. The Godot public API now matches the non-experimental GSDKs (C#, Java): start(), ready_for_players(), log_message(), register_health_callback(), register_shutdown_callback(), register_maintenance_callback(), update_connected_players(), get_game_server_connection_info(), get_logs_directory(), get_shared_content_directory(), get_initial_players(), get_config_settings(). See commit f50d61f.

@dgkanatsios
Copy link
Contributor

@copilot can you add a note in the main README that experimental GSDKs are not officially supported by PlayFab, just with a best effort support on GitHub/MSFT Game Dev Discord?

Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 7, 2026

@copilot can you add a note in the main README that experimental GSDKs are not officially supported by PlayFab, just with a best effort support on GitHub/MSFT Game Dev Discord?

Added an "Experimental GSDKs" section to the main README noting they are not officially supported by PlayFab and are provided on a best-effort basis, with links to GitHub Issues and MSFT Game Dev Discord for help. See commit 719cf25.

@dgkanatsios
Copy link
Contributor

@copilot can you make sure that the Godot code follows any established Godot coding guidelines?

Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
@dgkanatsios
Copy link
Contributor

@copilot can you also add unit tests?

Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 9, 2026

@copilot can you make sure that the Godot code follows any established Godot coding guidelines?

Reviewed all GDScript files against the official GDScript style guide and applied the following fixes in ba666c9 and 9f03c5f:

  • Moved ## doc comments after extends declarations (per code order: @toolclass_nameextends## docstring)
  • Renamed signal to past tense: transitioned_to_active (style guide: "Use the past tense to name signals")
  • Broke long lines to stay under 100 characters (function signature and config map assignment)
  • Added spaces inside single-line dictionary literal: { "PlayerId": ... }
  • Used := type inference for _logger variable (static typing encouraged)
  • Used descriptive variable name shared_content_folder instead of generic shared

Files already correct: tab indentation, snake_case functions/variables, PascalCase class names, CONSTANT_CASE constants/enum members, two blank lines between functions, trailing commas in multi-line collections, double quotes for strings, return type annotations on all functions.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • docs.godotengine.org
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: dgkanatsios <8256138+dgkanatsios@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 9, 2026

@copilot can you also add unit tests?

Added 40 unit tests in 3 test files using the GUT (Godot Unit Testing) framework in experimental/godot/tests/:

  • test_types.gd (13 tests) — enum serialization for all GameState/GameOperation values, unknown/empty string handling, config key constant values
  • test_internal_gsdk.gd (20 tests) — config map creation (all fields, missing fields, non-dict inputs), state transitions (Continue/Active/Terminate), signal emission, shutdown callback invocation, session config processing, initial players, metadata, maintenance callback deduplication, idempotent start
  • test_gsdk_logger.gd (7 tests) — directory/file creation, log level formatting (INFO/WARN/ERROR/DEBUG), graceful handling without initialization

Tests require Godot runtime to execute (same as the Go SDK tests requiring Go runtime). README updated with GUT setup and run instructions. See commit 040ea02.

@dgkanatsios dgkanatsios marked this pull request as ready for review March 9, 2026 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants