Skip to content

feat(unity): add RpcTo targeted client delivery#345

Closed
from2001 wants to merge 1 commit intodevelopfrom
codex/add-rpcto-functionality-for-target-clients
Closed

feat(unity): add RpcTo targeted client delivery#345
from2001 wants to merge 1 commit intodevelopfrom
codex/add-rpcto-functionality-for-target-clients

Conversation

@from2001
Copy link
Collaborator

Motivation

  • Provide the Unity client API a way to send RPCs to one or more specific clients instead of always broadcasting to the whole room.
  • Preserve existing Rpc(...) broadcast behaviour while enabling targeted delivery without server protocol changes.

Description

  • Added NetSyncManager.RpcTo(int targetClientNo, ...) and NetSyncManager.RpcTo(int[] targetClientNos, ...) to the Unity runtime to expose single/multi-target RPC sends via RpcTo.
  • Extended RPCManager with SendTo(...), BuildTargetedFunctionName(...) and TryResolveTargetedFunctionName(...) to encode targets into the outgoing function name using an internal @target: prefix and to decode/resolve it on receive.
  • Updated MessageProcessor to call RPCManager.TryResolveTargetedFunctionName(...) when processing MSG_RPC messages and to drop RPCs that are not addressed to the local client, while invoking local handlers with the original (decoded) function name.
  • Implementation avoids server changes by encoding target metadata in the RPC function name and keeps existing Rpc(...) broadcast semantics unchanged.

Testing

  • Ran repository structural/check command git diff --check and ensured no whitespace/diff-check issues were reported (success).
  • Performed code inspection of changed files NetSyncManager.cs, RPCManager.cs, and MessageProcessor.cs to verify the send/receive target encoding and decoding logic was added.
  • Note: No Unity Editor compile/play tests or Python unit tests were executed in this environment; manual verification in Unity Editor using Demo-01.unity or Debug Scene.unity with the server running is recommended.

Codex Task

@from2001
Copy link
Collaborator Author

We'll use #348

#286 #345 #346 #347 #348
Title Add targeted RPC transmission by ClientNo Add RpcTo targeted client delivery Add targeted RpcTo delivery API Add RpcTo targeted client delivery Add targeted RpcTo delivery by client number
Approach New MSG_RPC_TARGETED message type + ROUTER→DEALER direct delivery Encode targets in function name @target:1,2:Fn, filter in MessageProcessor Wrap as system RPC @system:rpc_to with JSON payload Encode targets in function name @target[1,2]|Fn, filter in OnRPCReceivedHandler Extend existing MSG_RPC binary format with targetClientNos field
Lines changed +2335 / -89 +93 / -4 +81 / -0 +106 / -0 +106 / -17
Files changed 15 3 (Unity) 1 (Unity) 2 (Unity) 6 (Unity + Python)
Server changes Yes (new message type + ROUTER delivery) None None None Yes (server-side filtering in _send_rpc_to_room)
Protocol change New message type ID (11) None None None Extends existing RPC binary format

@from2001 from2001 closed this Feb 27, 2026
@from2001 from2001 deleted the codex/add-rpcto-functionality-for-target-clients branch March 1, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant