Skip to content

feat: Unity client SDK (continuation of #1105)#1516

Open
ChiragAgg5k wants to merge 179 commits into
masterfrom
unity-client-sdk-continued
Open

feat: Unity client SDK (continuation of #1105)#1516
ChiragAgg5k wants to merge 179 commits into
masterfrom
unity-client-sdk-continued

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

Summary

This PR continues the work started by @Fellmonkey in #1105 to add comprehensive Unity SDK support to the SDK generator.

What was done

  • Rebased/fetched the original unity-client-sdk branch from Unity client sdk #1105
  • Created a new branch unity-client-sdk-continued preserving all original commits from the community PR
  • Merged latest master and resolved conflicts (notably in templates/dotnet/Package/Models/Model.cs.twig)

Original PR content (from #1105)

  • Unity Language Implementation: Introduces a new Unity language class (src/SDK/Language/Unity.php) that extends the base Language class, providing Unity-specific type mappings, keywords, and code generation logic for C# in Unity environment.
  • Unity Template System: Adds a complete set of Unity-specific templates under templates/unity/Assets/ including:
    • Runtime components (Client, Services, Models, Enums, etc.)
    • Editor tools (Setup Assistant, Setup Window)
    • Unity project files (assembly definitions, project settings)
    • Required .NET libraries for Unity compatibility
  • Automated Testing Integration: Introduces Unity2021 test support with:
    • Unity2021Test.php test class that integrates with the existing test framework
    • Unity test source files (Tests.cs, Tests.asmdef) for comprehensive SDK testing
    • Docker-based Unity CI testing using unityci/editor:ubuntu-2021.3.45f1-base-3.1.0
  • CI/CD Integration: Updates the GitHub Actions workflow to:
    • Include Unity2021 in the test matrix alongside other SDK platforms
    • Set up the UNITY_LICENSE environment variable for Unity Editor automation
    • Enable automated testing of the Unity SDK in the CI pipeline
  • Unity Project Structure: Implements proper Unity package structure with:
    • Assets organized under Assets/Runtime/ and Assets/Editor/
    • Required Unity project settings and manifest files

Changes from original PR

  • Resolved merge conflicts with current master
  • Preserved all original author commits and attribution

Closes #1105

Moved Unity SDK template files from 'templates/unity/Runtime' and 'templates/unity/Editor' to 'templates/unity/Assets/Runtime' and 'templates/unity/Assets/Editor' for better alignment with Unity project conventions. Updated getFiles() in Unity.php to reflect new paths and added support for copying plugin DLLs and project settings. Improved file upload logic in Client.cs.twig to handle streams and byte arrays more robustly, and removed Unity-specific logging from Exception.cs.twig. Minor fixes in Realtime.cs.twig and Role.cs.twig for namespace and async handling.
Introduces Unity2021 test support by adding a Unity2021Test.php, Unity test source files, and updating the GitHub Actions workflow to include Unity2021 in the test matrix and set the UNITY_LICENSE environment variable. This enables automated testing for the Unity SDK within the CI pipeline.
@ChiragAgg5k ChiragAgg5k force-pushed the unity-client-sdk-continued branch 3 times, most recently from b4a302b to 00c4e0b Compare May 11, 2026 05:23
Comment thread templates/unity/Assets/Runtime/Core/Client.cs.twig
@ChiragAgg5k ChiragAgg5k force-pushed the unity-client-sdk-continued branch from 00c4e0b to 96474f5 Compare May 11, 2026 06:43
…ntinued

# Conflicts:
#	.github/workflows/tests.yml
#	src/SDK/SDK.php
Comment thread templates/unity/Assets/Runtime/Realtime.cs.twig
Comment thread templates/dotnet/Package/Models/Model.cs.twig
Comment thread templates/unity/Assets/Runtime/Core/Client.cs.twig Outdated
internal class RealtimeConnectedData
{
[JsonPropertyName("user")]
public Dictionary<string, object> User { get; set; }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a question here, do we need a dict here? user is always a single one for a client unlike subscriptions. A single client = single user

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 89dd7f3: connected.user is no longer modeled as a dictionary map type; it is now handled as a single JSON object (JsonElement) and checked as an object payload.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot One concern -> I am not aware in c# websockets. Presence and Subscribe are two independent messages.
Earlier we used to follow this->

  • on the first subscribe only we open the websocket

Same thing should be done for the presence as well.
But here one thing is coming -> due to two different variants we need to make sure only one socket connection is opened and they are sent after the 'connected' is received

So a lock should be held always here.
Can you check this part

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 89dd7f3: subscribe and presence now share a serialized send path guarded by a lock, and sends are deferred until after the app-level connected message. I also kept single-flight socket creation and allowed presence-only socket open (_channels.Count == 0 && _pendingPresence == null guard).

Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

@ArnabChatterjee20k Unfortunately I hit an unexpected error while processing your comment. I've automatically reported this to GitHub.

You can ask me to try again later by mentioning me in a new comment.

If you want to contact GitHub about this error, please mention the following identifier so they can better serve you: 343946e8-991b-4e7a-8637-2df8480360c0

Sorry for the inconvenience!

Metadata = metadata
};

if (_webSocket?.State == WebSocketState.Open)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we should do it in a lock based synchronised way. same in the subscribe

Comment thread tests/Unity2021Test.php
ChiragAgg5k and others added 2 commits May 19, 2026 13:21
Copy link
Copy Markdown
Contributor

Copilot AI commented May 19, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

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:

  • 140.82.113.3
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack &#39;php-fig/log.git&#39; set-url origin ndor/bin/git sdk-generator/vegrep 54c9ad64 tnet/tools/git git remo�� ps://github.com/symfony/polyfill-php81.git&#39; composer ndor/bin/git e/path-converterbash origin mann/php-timer.g--noprofile git (packet block)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack &#39;php-http/discovery.git&#39; -r git ps k/sdk-generator/bash 4d383bb95465193f/usr/bin/runc t ps chec�� git -- (packet block)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack &#39;composer/semver.git&#39; --hard fdfc727f0fcacfebtouch e/git-remote-htt-c ill-php81.git -- k 5262 on REDACTED--noprofile e/git-remote-https clon�� xymds9a16iq/config.json -- ndor/bin/php git 2c95e1e86cb8dd41-c (packet block)
  • 140.82.113.4
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack &#39;protocolbuffers/protobuf-php.git&#39; 11.0.12 -- /usr/local/.ghcup/bin/git aratest.git t ndor/bin/git git rese�� --hard 4f7fd7836c6f332bb2933569e566a0d6c4cbed74 e/git-remote-https e/path-converter/usr/libexec/docker/docker-init -- ndor/bin/git e/git-remote-https (packet block)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack &#39;opentelemetry-php/context.git&#39; git -- (packet block)
  • github.com (HTTP Only)
    • Triggering command: /usr/bin/ssh /usr/bin/ssh -o SendEnv=GIT_PROTOCOL git@github.com git-upload-pack &#39;Jean85/pretty-package-versions.git&#39; add composer nfig/composer/vendor/bin/git om/phar-io/manifgit -- (packet block)
  • https://api.github.com/repos/Jean85/pretty-package-versions/zipball/4d7aa5dab42e2a76d99559706022885de0e18e1a
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/matthiasmullie/minify/zipball/76ba4a5f555fd7bf4aa408af608e991569076671
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/matthiasmullie/path-converter/zipball/e7d13b2c7e2f2268e1424aaed02085518afa02d9
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/paratestphp/paratest/zipball/130a9bf0e269ee5f5b320108f794ad03e275cad4
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/OxIU41 /usr/bin/composer install --ignore-platform-reqs --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/15c5dd40dc4f38794d383bb95465193f5e0ae180
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/183a9b2632194febd219bb9246eee421dad8d45e
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit/zipball/54391c61e4af8078e5b276ab082b6d3c54c9ad64
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/comparator/zipball/2c95e1e86cb8dd41beb8d502057d1081ccc8eca9
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/complexity/zipball/ee41d384ab1906c68852636b6de493846e13e5a0
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d36ad0d782e5756913e42ad87cb2890f4ffe467a
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2c1ed04922802c15e1de5d7447b4856de949cf56
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/118cfaaa8bc5aef3287bf315b6060b1174754af6
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/c1ca3814734c07492b3d4c5f794f4b0995333da2
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3e0404dc6b300e6bf56415467ebcb3fe4f33e964
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3b415def83fbcb41f991d9ebf16ae4ad8b7837b3
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/fdfc727f0fcacfeb8fcb30c7e5da173125b58be3
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/symfony/console/zipball/c28ad91448f86c5f6d9d2c70f0cf68bf135f252a
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/OxIU41 /usr/bin/composer install --ignore-platform-reqs --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-ctype/zipball/a3cc8b044a6ea513310cbd48ef7333b384945638
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/OxIU41 /usr/bin/composer install --ignore-platform-reqs --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/OxIU41 /usr/bin/composer install --ignore-platform-reqs --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/OxIU41 /usr/bin/composer install --ignore-platform-reqs --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-mbstring/zipball/6d857f4d76bd4b343eac26d6b539585d2bc56493
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/OxIU41 /usr/bin/composer install --ignore-platform-reqs --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/symfony/process/zipball/608476f4604102976d687c483ac63a79ba18cc97
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/OxIU41 /usr/bin/composer install --ignore-platform-reqs --no-interaction (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/45112560a3ba2d715666a509a0bc9521d10b6c43
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/OxIU41 /usr/bin/composer install --ignore-platform-reqs --no-interaction (http block)
  • https://api.github.com/repos/theofidry/cpu-core-counter/zipball/db9508f7b1474469d9d3c53b86f817e344732678
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/twigphp/Twig/zipball/0b6f9d8370bb3b7f1ce5313ed8feb0fafd6e399a
    • Triggering command: REDACTED, pid is -1 (http block)

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

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.

5 participants