Rpc
Namespace: SynicSugar.P2P
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class RpcAttribute : Attribute
Description
Invoke method in local and other peers' instance.
Can send 1st argument (that can serialize with MemoryPack.
When argument is over 1170 bytes, make true the first argument of RPC. SynicSugar can send it up to 296960 Bytes (about 300KB) as LargePacket.
Normally, RPC is sent to one peer per frame, but by p2pConfig.RPCBatchSize, it can be sent to multiple peers within the same frame.
EOS has Packet reliability, but the packet can not be reached to disconnected peers. When shouldRecordLastPacketInfo is true, can get payload info from p2pInfo that packets that must be sent.
ConnectHub.Instance.ResendLastRPC,
ConnectHub.Instance.ResendLastRPCToTarget
If an error occurs due to around namespace, we need write the full path(like System.CollectionGeneric.AAA()) and it will pass. I will fix this issue in future.
Constructor
API | description |
---|---|
Rpc() | Standard RPC |
Rpc(bool isLargePacket, bool shouldRecordLastPacketInfo) | Exceed 1170 bytes? Record latest payload? |
using SynicSugar.P2P;
[NetworkPlayer]
public partial class NetworkSample {
[Rpc]
public void StandardRpc(string message){
}
[Rpc(true, false)]
public void LargePacketRpc(string message){
}
[Rpc(false, true)]
public void ImportantRpc(string message){
}
}