feat: add targeted RPC delivery by client number#348
Merged
Conversation
Collaborator
Author
|
We'll use #348
|
This was referenced Feb 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for sending RPCs to specific client number(s) (instead of always broadcasting), by extending the RPC payload with an optional target list and updating server routing accordingly.
Changes:
- Unity: adds targeted RPC public API overloads that forward to
RPCManager.SendTo(...)when targets are provided. - Server: updates
_send_rpc_to_roomto unicast RPCs only to specified target client numbers (broadcast otherwise). - Python serializer: extends RPC binary frame to include
targetClientNosascount (byte) + ushort[].
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs | Adds new public RPC overloads intended to support targeted delivery. |
| STYLY-NetSync-Server/src/styly_netsync/server.py | Routes RPCs to specific client identities when targetClientNos is present; otherwise broadcasts. |
| STYLY-NetSync-Server/src/styly_netsync/binary_serializer.py | Serializes/deserializes targetClientNos in the RPC wire format. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs
Show resolved
Hide resolved
Collaborator
|
LGTM |
Collaborator
Author
|
Closed #239 |
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Motivation
Rpc()overloads rather than introducing a separateRpcTo()method.Description
Unity Client:
NetSyncManager.Rpc(functionName, args, int targetClientNo)andRpc(functionName, args, int[] targetClientNos)overloads. When no targets are given (or the array is empty), it falls back to broadcast.RPCMessageinDataStructure.cswithint[] targetClientNosfield.BinarySerializer.csto serialize/deserialize targets ascount(1 byte) + clientNos(N × ushort)in the RPC frame.RPCManagerwithSendTo()internal method, preserving target info through the pending queue, size estimation, and offline loopback filtering.Python Server:
binary_serializer.pyto serialize/deserializetargetClientNosin the RPC message.server.py_send_rpc_to_room(): whentargetClientNosis non-empty, unicasts via ROUTER only to specified clients; otherwise broadcasts to the whole room.Python Client API:
target_client_nosoptional parameter toclient.pyrpc()method so Python clients can also send targeted RPCs.Documentation:
CLAUDE.mdand UnityCLAUDE.mdto document RPC targeting capability.Tests:
test_binary_serializer.py: broadcast, single target, multi-target, max 255 targets, overflow, None/missing treated as broadcast, UTF-8 function name.Testing
pytest tests/test_binary_serializer.py— 8/8 RPC tests passedblack src/ tests/ && ruff check src/ tests/ && mypy src/— all passedCodex Task