Skip to main content

Room

OBR.room

The room API gives you access to the current room the extension is being used in.

Reference

Properties

NAMETYPEDESCRIPTION
idstringA unique ID for the current room.

Methods

getPermissions

async getPermissions()

Get the current permissions for players in this room.

Returns a Permission array.


onPermissionsChange

onPermissionsChange(callback);

Parameters

NAMETYPEDESCRIPTION
callback(permissions: Permission[]) => voidA callback for when the permissions of the current room changes

Returns a function that when called will unsubscribe from change events.

Example

/**
* Use an `onPermissionsChange` event with a React `useEffect`.
* `onPermissionsChange` returns an unsubscribe event to make this easy.
*/
useEffect(
() =>
OBR.room.onPermissionsChange((permissions) => {
// React to rooms permissions change
}),
[]
);

getMetadata

async getMetadata()

Get the current metadata for this room.

returns a Metadata object.


setMetadata

async setMetadata(update)

Update the metadata for this room.

See Metadata for best practices when updating metadata.

Room metadata is intended for small bits of stored data for an extension.

In total the room metadata must be under 16kB.

Parameters

NAMETYPEDESCRIPTION
updatePartial<Metadata>A partial update to this rooms metadata. The included values will be spread among the current metadata to avoid overriding other values.

onMetadataChange

onMetadataChange(callback);

Parameters

NAMETYPEDESCRIPTION
callback(metadata: Metadata) => voidA callback for when the metadata of the current room changes

Returns a function that when called will unsubscribe from change events.

Example

/**
* Use an `onMetadataChange` event with a React `useEffect`.
* `onMetadataChange` returns an unsubscribe event to make this easy.
*/
useEffect(
() =>
OBR.room.onMetadataChange((metadata) => {
// React to rooms metadata changes
}),
[]
);