Skip to content
This repository has been archived by the owner on Aug 15, 2022. It is now read-only.

Replacing Previous Buffered RPCs

Daniel McGuinness edited this page Sep 30, 2018 · 2 revisions

There are times where the buffered data that you want to send to new players that connect needs to be updated. Let's say that you were sending the current color of the winning team to a connecting player. Though you could run this on playerAccepted you might choose to do this with a buffered RPC.

Unfortunately the currently winning team may change and so the color would need to be buffered yet again. If you were to keep buffering the team color you may end up with a buffer of 50 RPCs, so all 50 would get sent in order to the connecting player. Instead you can choose to replace the last call to a buffered RPC which will remove the last RPC called on this specific game object with the given RPC string name with the one you are currently executing. This is done easily by passing true to the SendRpc method overload that has the replacePrevious argument:

bool replacePrevious = true;
networkObject.SendRpc(RPC_MY_RPC_NAME, replacePrevious, Receivers.AllBuffered, new object[] { "args go here" });

Home

Getting Started
Network Contract Wizard (NCW)
Network Object
Remote Procedure Calls (RPCs)
Unity Integration
Basic Network Samples
Scene Navigation
NetWorker
Master Server
Web Server
Netcoding Design Patterns
Troubleshooting
Miscellaneous
Forge Networking Alloy
Steamworks
Clone this wiki locally