setState

If reliable is true, the state is synced reliably via WebSockets. If false, state is synced faster via WebRTC but less reliably.

Signature

function setState(key: string, value: any, reliable?: boolean): void

Parameters

NameTypeDescription
keystringThe state key to set.
valueanyThe value to set for the key.
reliable?booleanWhether the update should be reliably synced to all players. Defaults to true.

Usage

setState('winner', 'player1');