Tip |
---|
This How-To assumes you have completed the quick start and have an exhibit connected to Gumband Cloud |
Handling Operating Modes
...
Note |
---|
The Operating Mode feature has been deprecated in Gumband. We’ve learned that most exhibits on the platform were not using the feature and the switch in the UI was confusing to many users. The original Operating Mode feature is still available for developers to implement it in their exhibits, but is now disabled by default. |
Basic Description
An exhibit can be set to one of two operating modes in Gumband: on “On” or off. The “Off”. When the feature is enabled, the operating mode can be toggled through the Gumband UI on the Exhibit Settings tab:
...
Enabling The Operating Mode Feature
To enable the Operating Mode feature for your exhibit, all you need to do is set the Operating Mode to either the “On” or “Off” mode via the Gumband SDK’s setOperatingMode
method [see: API Reference (V2.0.0 - Latest)]. Once the mode is set, the Operating Mode Setting will appear on your exhibit’s Settings tab which will behave like a normal setting.
Code Block | ||
---|---|---|
| ||
import { Gumband } from "@deeplocal/gumband-node-sdk";
import { MANIFEST } from "./manifest.js";
this.gumbandSDK = new Gumband(
process.env.EXHIBIT_TOKEN,
process.env.EXHIBIT_ID,
MANIFEST
);
this.gumbandSDK.on('READY', async () => {
// *** Setting the Operating Mode to enable the feature.
// *** Once the Operating Mode has been set once, the line below can be removed
await this.gumbandSDK.setOperatingMode(true);
}); |
Note:
...
You only need to set the Operating Mode once from the SDK to enable the feature, once the Operating Mode has been set. Meaning if you don’t want your exhibit to set the Operating Mode every time it starts, you don’t have to.
Handling Operating Modes
You can listen for changes in the operation operating mode through the Sockets.OP_MODE_RECEIVED
event listener callback on the SDK:
Code Block | ||
---|---|---|
| ||
this.gumbandSDK.on(Sockets.OP_MODE_RECEIVED, (payload) => { console.log(`received op mode: ${JSON.stringify(payload)}`); if(payload.value) { console.log('OP mode now on'); } else { console.log('OP mode now off'); } }); |
...