Table of Contents |
---|
SDK HARDWARE_ONLINE
& HARDWARE_OFFLINE
Callbacks
The exhibit SDK emits a HARDWARE_ONLINE
event with the after a hardware connection is established and successfully authenticates. It also emits a HARDWARE_OFFLINE
event if the MQTT heartbeat for a particular harwareId
connection isn’t received by the SDK within 20 seconds.
Code Block |
---|
// gumband sdk initalization above...
// register hardware connection callbacks
gb.on(Sockets.HARDWARE_ONLINE, (payload) => {
console.log(payload);
});
gb.on(Sockets.HARDWARE_OFFLINE, (payload) => {
console.log(payload);
}); |
Both events contain the following payload
:
Code Block |
---|
{
hardwareId: 123,
name: 'Exhibit Gizmo'
} |
SDK Hardware Authentication Scenarios
...
SDK “Waiting for Auth” Queue
Had to add a “waiting for auth” state where hardware sockets would connect, but the exhibit hasn’t received the connected If the exhibit SDK has not yet received the hardware list from the platform yet (Gumband Cloud but is expecting to (ie. noInternetConnection: false
and the SDK is initializing or the exhibit is temporarily offline). When it does, it would send the message to ask for auth on that client. If it doesn’t, it will disconnect is 10s
and then assuming the hardware would try to reconnect and repeat the cycle until it connects.
TODO: If the SDK disconnects due to no hardwareID in this queue, it should respond per the updated MQTT spec.
...
, the SDK holds hardware connections in a “Waiting for Auth” queue as it waits for the hardware list. When the SDK adds connections to this queue, it doesn’t request the auth token from the connection immediately but instead just holds the connection. If the SDK doesn’t receive the hardware list from the Gumband Cloud within 10 seconds, it will disconnect the hardware connection assuming that the hardware will try to reconnect, and repeat that cycle until the Gumband Cloud connection is re-established.
How Two MQTT Connections for the Same Hardware ID Respond
If two connections try to authenticate with the same hardwareId
, the SDK responds whether or not the existing connection is authenticated. If that case is true, then the new hardware connection is rejected. If the existing connection is not authenticated (ie. in the “Waiting for Auth” queue), then that connection will be severed and the new connection will be accepted.
SDK HARDWARE_ONLINE
& HARDWARE_OFFLINE
Callbacks
The exhibit SDK emits a HARDWARE_ONLINE
event with the after a hardware connection is established and successfully authenticates. It also emits a HARDWARE_OFFLINE
event if the MQTT heartbeat for a particular harwareId
connection isn’t received within 20 seconds. Both events contain the following payload
...