Description

Check to see if p5.party has designated this guest as the room’s host.

p5.party designates exactly one guest in each occupied room as its host at all times.

Syntax

partyIsHost()

Parameters

none

Returns

boolean: true if the client is the host, false if the client is not the host

Examples

Reset shared data if we connect to an empty room.

let shared;

function preload() {
  partyConnect(...);
  shared = partyLoadShared("globals");
}

function setup() {
  ...
  // if this client is host during setup it is the first/only guest in the room
  if (partyIsHost()) {
    partySetShared(shared, {score: 0});
  }
}