/** Create instance */
const qnet = new QNetWebSocketBrowser();
/** Connect to server (server is running in docker) */
qnet.connect().then(async () => {
/** Update connection status */
setConnectionInfo("Connected");
/** Get machine instance */
const machine = MachineSimulator.getInstance();
/** Start the machine and its id */
const id = await machine.start();
/** Subscribe to the `id/your/topic` topic */
qnet
.getSubPub()
.subscribe(`${id}/your/topic`, (message: QNetWebSocketMessage) => {
/** Process the message */
processAnalog(message);
});
/** Publish to the `id/your/topic` topic */
qnet
.getSubPub()
.publish(`${id}/your/topic`, JSON.stringify({your: 'data'}));
});