Skip to content
PEERLESSDocs

Function reference

Every method on window.Peerless, grouped by area.

Core

MethodReturnsNotes
init(options?)Promise<Context>mode, parentOrigin, mapPlayerIdentity. Call once.
ready()Promise<{ room, runtime, capabilities }>Low-level handshake used by init().
runtime()Promise<PlatformRuntime>Fresh identity and launch credentials.
asset(path)stringResolves an export-relative path, or an https, data or blob URL.
fullscreen(element?)Promise<unknown>Asks the player for fullscreen; standalone uses the element.
on(type, listener)() => voidSubscribes to an event.
version · protocolstring · 2SDK version and protocol.

Player UI

MethodReturnsNotes
ui.open(panel?)Promise<boolean>menu, party, friends, chat, profile, settings, achievements, leaderboards.
openPlayerMenu()Promise<unknown>Kept for existing games; prefer ui.open("menu").
player.snapshot(state)Promise<unknown>Publishes your match roster to the overlay.
player.event(event)Promise<unknown>Reports connected, reconnecting, closed, removed or expired.

Social

MethodReturns
social.snapshot()Promise<SocialSnapshot>
social.me()Promise<SocialProfile & { guest }>
social.friends()Promise<SocialFriend[]>
social.party()Promise<SocialParty | null>
social.profile(playerId)Promise<SocialProfile>
social.onChange(listener)() => void

Progress and analytics

MethodReturnsNotes
analytics.gameplayReady()Promise<unknown>Loaded and controllable; starts heartbeats.
analytics.roundCompleted()Promise<unknown>A real round finished.
achievements.list()Promise<{ achievements, unlocked, total }>Catalog with progress.
achievements.unlock({ key, eventId })Promise<{ ok, duplicate, unlocked, key, title? }>Binary achievements.
achievements.setProgress({ key, value, eventId })Promise<{ ok, duplicate, unlocked, key, progress? }>Absolute cumulative value.
leaderboards.submit({ boardId, score, submissionId? })Promise<unknown>Reuse the submission ID on retry.
leaderboards.list({ boardId?, period?, scope? })Promise<unknown>period: all, week or a Monday date; scope: global, friends, nearby.

Audio

MethodReturns
audio.state()PlayerAudio ({ muted, volume })
audio.onChange(listener)() => void

Sessions

MethodReturnsNotes
sessions.bind(adapter)() => voidBinds your SessionAdapter.
sessions.ready({ lobbyId })Promise<void>Starts lobby polling.
sessions.queue({ mode? })Promise<unknown>Solo or the verified party cohort.
sessions.cancel() · wait() · retry()Promise<unknown>Queue recovery.
sessions.reconnect()Promise<unknown>Calls your adapter's reconnect hook.
sessions.reportState(state)Promise<unknown>loading, lobby, queueing, match, reconnecting, closed.
sessions.current() · onStatus(listener)Snapshot · () => voidThe current platform session.
sessions.host(options?) · join(options) · list(options?)Promise<unknown>Require adapter support and declarations.
sessions.connection({ region? })Promise<PlatformRuntime>Regional endpoint and token.
sessions.listen(options?)Promise<ListenTransport>WebRTC listen hosting.
sessions.onHostChange(listener)() => voidHost elections.
sessions.reportQuality(metrics) · signal(packet)Promise<unknown>Hybrid transport hooks.
sessions.dispose()voidStops polling and disposes the adapter.

Rooms and managed credentials

MethodReturnsNotes
join(code?)Promise<void>Relay room (ten-character code).
send(event)voidUnder 16 KiB.
leave()voidLeaves and stops reconnecting.
managed({ onRuntime?, onError? }){ ready, refresh, current, dispose }Short-lived server credentials.