Struct RpcQueue<TActionSerializer, TActionRequest>
A helper struct that should be used schedule outgoing RPCs.
The RpcQueue is used internally by the code-generated systems that consume the
Send
You can use the RpcQueue in your custom system by retrieving an instance for the given
TActionRequest
, TActionSerializer
pair from the Rpc
Inherited Members
Namespace: Unity.NetCode
Assembly: Unity.NetCode.dll
Syntax
public struct RpcQueue<TActionSerializer, TActionRequest> where TActionSerializer : struct, IRpcCommandSerializer<TActionRequest> where TActionRequest : struct, IComponentData
Type Parameters
Name | Description |
---|---|
TActionSerializer | The typename of the struct implementing the IRpc |
TActionRequest | The typename of a struct implementing the IComponent |
Remarks
If you intend to cache the retrieved queue (e.g. inside an OnCreate function in your system),
you must ensure that your system is created after the Rpc
Methods
Schedule(DynamicBuffer<OutgoingRpcDataStreamBuffer>, ComponentLookup<GhostInstance>, TActionRequest)
Schedules an rpc to be sent through the network, by serializing and appending a new
rpc packet into the Outgoing
The binary rpc data has the following format:
- PacketType: short or long based on the Dynamic
- MsgLen: short, the length of the serialized data.
- RpcData: the binary data generated by invoking the TActionSerializer
serialize method.
Declaration
public void Schedule(DynamicBuffer<OutgoingRpcDataStreamBuffer> buffer, ComponentLookup<GhostInstance> ghostFromEntity, TActionRequest data)
Parameters
Type | Name | Description |
---|---|---|
Dynamic |
buffer | Stream buffer for the rpc packetsk |
Component |
ghostFromEntity | Lookup for ghost instance |
TAction |
data | data |
Exceptions
Type | Condition |
---|---|
Invalid |
If the RPC index cannot be found for the rpc type. |