Skip to content

feat(unity): add targeted RpcTo delivery API#346

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

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

Conversation

@from2001
Copy link
Collaborator

Motivation

  • Provide a way for Unity clients to send RPCs to one or more specific clients while preserving existing broadcast behavior.
  • Maintain compatibility with the current server protocol without adding new server-side message types.
  • Keep RPC filtering logic client-side so that non-targeted clients ignore targeted RPCs.

Description

  • Add overloaded APIs RpcTo(int targetClientNo, string functionName, string[] args = null) and RpcTo(int[] targetClientNos, string functionName, string[] args = null) to NetSyncManager for single and multi-target sends.
  • Introduce TargetedRpcPayload and SystemRpcToFunctionName = "rpc_to" and serialize the payload with JsonConvert.SerializeObject to send as an internal system RPC via Rpc_SystemRPC.
  • Extend the system RPC handler to handle rpc_to by deserializing the payload in HandleTargetedRpc, checking if the local _clientNo is included in targetClientNos, and invoking OnRPCReceived only for matching targets.
  • Changes are localized to STYLY-NetSync-Unity/Packages/com.styly.styly-netsync/Runtime/NetSyncManager.cs and do not alter the broadcast Rpc(...) behavior.

Testing

  • Ran git diff --check to validate whitespace and patch issues and it completed without errors.
  • Searched for the new symbols with rg -n "public void RpcTo|HandleTargetedRpc|SystemRpcToFunctionName" to verify the additions and the search returned the expected locations.
  • Performed quick file inspection of NetSyncManager.cs to confirm insertion points and handler wiring succeeded and found no compile-time formatting issues.

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-93yxs6 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