Skip to content

State and RPC

State and RPC are sub-capabilities of Multiplayer lobby. State synchronizes shared room or player data, while RPC triggers named logic in the room. Both are used after the player joins a room.

EngineStatusNotes
UnityPreviewSupports state set / get / reset and RPC register / call / unregister.
GameMakerNot supportedThe first GameMaker release does not include state or RPC.
GodotIn developmentThe preview runtime already has JSON state and RPC calls.
  • The minimal Rooms flow is complete.
  • A room has been joined.
  • State keys and RPC names should remain stable.
using System;
using UnityEngine;
using IGP.Multiplayer;
public sealed class IGPStateRpcDriver : MonoBehaviour
{
[SerializeField] private IGPMultiplayerRuntime runtimeManager;
public async void SetGlobalScore()
{
await runtimeManager.SetGlobalStateAsync("match.score", new
{
red = 1,
blue = 0,
updatedAt = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
});
}
public async void RegisterEchoRpc()
{
await runtimeManager.RegisterRPCAsync("sample.echo");
}
public async void CallEchoRpc()
{
var requestId = await runtimeManager.CallRPCAsync(
"sample.echo",
new { text = "hello" },
"all");
Debug.Log($"RPC request id={requestId}");
}
}

Receive state and RPC messages through IGPMultiplayerRuntime.MessageReceived, then dispatch state_set, state_get, state_reset, rpc_call, or rpc_response message types. The SDK converts Content to StateSetContent, StateGetResponseContent, StateResetResponseContent, RPCCallContent, or RPCResponseContent. Use GetValue<T>() / GetData<T>() for game data instead of parsing JObject. Reply with RespondRPCAsync and pass RPCCallContent.CallerPlayerId as the target player.

EngineCheckpoint
UnityState changes are received after setting state; registered RPCs can be called and responses received.
GameMakerState and RPC validation is not performed currently.
GodotSetStateJsonAsync, GetStateAsync, and CallRpcJsonAsync can complete in sequence.
  • State cannot be read: confirm scope and key match exactly.
  • RPC is not triggered: first confirm the corresponding RPC name has been registered.
  • Unity does not receive events: confirm IGPMultiplayerRuntime.MessageReceived is subscribed and inspect MessageType.
  • Godot JSON fails: validate with a simple object string first, such as {"value":1}.