qnet-websocket-browser
TypeScript icon, indicating that this package has built-in type declarations

0.0.0 • Public • Published

qnet-websocket-browser

Usage

Run the QNet Server

Front-End Example

import { QNetWebSocketBrowser } from "qnet-websocket-browser";
/** 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'}));
});

Dependencies (0)

    Dev Dependencies (11)

    Package Sidebar

    Install

    npm i qnet-websocket-browser

    Weekly Downloads

    2

    Version

    0.0.0

    License

    none

    Unpacked Size

    34.1 kB

    Total Files

    29

    Last publish

    Collaborators

    • drsanti