Skip to content

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

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

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

Conversation

@from2001
Copy link
Collaborator

Motivation

  • Provide an API to send RPCs from the Unity client to a specific client or a set of clients without changing existing broadcast behavior.

Description

  • Added RpcTo(int targetClientNo, string functionName, string[] args = null) and RpcTo(int[] targetClientNos, string functionName, string[] args = null) to NetSyncManager to expose single/multi-client directed RPC sends while leaving Rpc(...) unchanged.
  • Implemented RPCManager.SendTo(...) and helper methods to encode a target envelope into the function name using the internal format @target[2,3]|FunctionName and to sanitize targets (positive, unique client numbers).
  • Added RPCManager.TryExtractTargetedFunction(...) to decode the envelope and return the decoded function name plus the target client set.
  • Updated NetSyncManager.OnRPCReceivedHandler to use the decoder and drop incoming RPCs that include a target envelope but do not list the local ClientNo, so only intended recipients process the RPC.

Testing

  • No automated tests were executed for the Unity runtime code in this headless environment.

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

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