20
ModuleClientAPI
Mees van der Wijk edited this page 2026-01-28 13:43:58 +01:00

ModuleClientAPI - Documentation

The ModuleClientAPI is the heart of every interactive Getiyo module's front-end experience. Click here to view the introductions.

Sub Classes

GameLib

The GameLib inside the ModuleClientAPI.

api.GameLib;

Return GameLib The GameLib class

Communication

send

Send a message to the ModuleServerAPI.

api.send(header, ...args);
Argument Type Description
header string The header of the message.
args any[] Data of any type

on

Register a listener for messages from the ModuleServerAPI.

api.on(header, callback);
Argument Type Description
header string To header of the messages the listener will receive.
callback ( ...args:any [] ):void Function that receives the incomming message and arguments.

finishClientCondition

Finish a client condition for this client.

api.finishClientCondition(conditionId);
Argument Type Description
conditionId string The id of the condition.

Events

onDestroy

Register a listener for when the module is destroyed from the scene. Make sure you stop your clocks and render loops here.

api.onDestroy(callback);
Argument Type Description
callback ( ):void Function that will be called when the module gets destroyed.

onUserDetailsChange

Register a listener for when the user changes their details.

api.onUserDetailsChange(callback);
Argument Type Description
callback function Function that will be called when the user changed their details.

onResize

Register a listener for when the module changes size.

api.onResize(callback);
Argument Type Description
callback function Function that will be called when the module is resized.

onReconnect

Register a listener for when the module reconnects to the server.

api.onReconnect(callback);
Argument Type Description
callback function Function that will be called when the module is reconnected.

Getters

dom

Get the HTMLDivElement that contains the module HTML. It is important that all your query's to the document are based of this. So you need to use api.dom().querySeletor(p) instead of document.querySeletor(p) to prevent querying element from another module.

api.dom();

Returns HTMLDivElement The module container

getUser

Get the current user object.

api.getUser();

Return User The user object

getModuleID

Get the current module id.

api.getModuleID();

Return string The id of the module instance.

getSize

Get the size of the module.

api.getSize();

Returns { width:number, height:number } Size of the module.

getResolution

Get the scene resolution.

api.getResolution();

Returns { width:number, height:number } Resolution of scene.

getTime

Get the current server time. This is a live synced time with the Getiyo server. Use this if you depend on timing so each client will be sync.

api.getTime();

Returns number The unix timestamp synced with the server.

isInEditor

Check if the module is running in the editor.

api.isInEditor();

Returns boolean Running in editor.

Properties

onReferencePropertyChange

Register a listener for when a reference property updates in a scene change. The listener will also be called on initial module creation and when the property is changed in the editor.

api.onReferencePropertyChange(propertyId, callback);
Argument Type Description
propertyId string The property ID that the listener will receive.
callback ( property:Property, transitionDuration:number ):void Callback for when the reference property value changes.
propertyPropertyProperty instance.
transitionDurationnumberThe duration in milliseconds the transition should be.

getReferenceProperties

Get all module reference properties.

api.getReferenceProperties();
Argument Type Description
sceneId string The id of the scene where you want to get the properties of.

Returns { [ propertyId:string ]: Property } All reference properties

getReferenceProperty

Get a module reference property.

api.getReferenceProperty(propertyId);
Argument Type Description
propertyId string The id of the reference property you want to get.

Returns Property Reference property

hasReferenceProperty

Check if a module reference property exists.

api.hasReferenceProperty(propertyId);
Argument Type Description
propertyId string The id of the property you want to check.

Returns boolean Has reference property

Snapshots

onSnapshotRestore

Register a listener that will be called when a snapshot is recalled and the runtime storage is restored.

api.ononSnapshotRestore(callback);
Argument Type Description
callback Function Callback will be called when a snapshot is restored.

onSnapshotCreate

Register a listener that will be called before a snapshot is taken, this makes it possible to add variable to the storage before the snapshot happens.

api.onSnapshotCreate(callback);
Argument Type Description
callback Function Callback will be called before the snapshot is created.

getRuntimeStorage

Get the variable storage object.

api.getRuntimeStorage();

Returns RuntimeStorage The runtime storage object.

Playback

onAudioAllowed

Adds a listener for when audable audio playback is allowed.

api.onVolumeChange(callback);
Argument Type Description
callback Function Callback will be called when audable audio playback is allowed.

onVolumeChange

Adds a listener for volume change. Volume is a number between 0 and 1.

api.onVolumeChange(callback);
Argument Type Description
callback ( value:number ):void Callback with the new volume. Volume is a number between 0 and 1.

getVolume

Get the current volume of the renderer.

api.getVolume();

Returns number Volume (between 0 and 1).

onPlayStateChange

Adds a listener for the play state change.

api.onPlayStateChange(callback);
Argument Type Description
callback ( state: 'playing' / 'paused' / 'loading' ):void Callback for the play state has changed.

getPlayState

Get the current play state of the renderer.

api.getPlayState();

Returns 'playing' | 'paused' | 'loading' Current play state.

Neighbors

getNeighbors

Get one ore more module neighbors.

api.getNeighbors(filter);
Argument Type Description
filter { moduleId?:string, moduleType?:string, moduleTypes?:string[] } The filter other modules have to comply with.

Returns NeighborResults NeighborResults instance.

onNeighborMessage

Register a listener for incoming neighbor messages.

api.onNeighborMessage(header, callback);
Argument Type Description
header string The header to listen for.
callback ( neighbor:Neighbor, ...args ):void Callback for when a packet is received. Args is the data in the same order as when it was send.

Utils

redirect

Redirect user to another url. If the url is a channel on the same server and target is self it will redirect internally.

api.redirect(address target)
Argument Type Description
address string The new address to redirect to
target 'self' 'blank' 'parent' The target to open the page in.

Globals

Feedback (notifications, dialogs, confirms, alerts)

Use the internal feedback component. See feedback

ce

Util function to quickly create HTML elements.

ce(tagName, classList?, attributes?, innerText?, innerHTML?);
Argument Type Description
tagName keyof HTMLElementTagNameMap The tagname of the new element. (For example div)
(Optional) classList string | string[] Class(es) to add to the element.
(Optional) attributes { [key:string]:string } Attributes to set on the element.
(Optional) innerText Text to set as the inner content.
(Optional) innerHTML HTML to set as the inner content.

Returns HTMLElement New HTML element

loading

Show the system UI loader.

loading(zIndex);
Argument Type Description
zIndex number The z index lever on which to draw the loader.

loading

Hide the system UI loader.

hideLoading();

const CHANNEL

Current channel hostname.

CHANNEL;

const ID

Current channel id.

ID;

const DISPLAY

Current display id.

DISPLAY;