LibPIS
    Preparing search index...

    LibPIS

    Introduction

    The libPIS JavaScript library is a common library used to parse the MQTT topic and payload specified in MQTT PIS specification. It is a wrapper library of Paho MQTT client https://www.eclipse.org/paho/files/jsdoc/Paho.MQTT.Client.html which uses MQTT over Websockets to receive MQTT data directly into a web browser.

    The libPIS library mostly will be used by broswer application type of MQTT clients to communicate with other MQTT clients over the MQTT broker.

    On reception of every subscribed MQTT topic, the state object will be updated with updated data.

    Installation

    <script src="https://libpis.dev.suite.luminator.com/libpis.js"></script>
    

    npm install @msetsuite/libpis

    Usage

    Configure your web app project's package.json file to include the version of the libpis library.

    Below is an example of using libpis library in HTML file.

    The config specifies the MQTT broker the libpis library shall connect to.

    If config is not configured, one can use window.luminator.pis.init(); which means by default the libpis library will connect to the MQTT broker at localhost, port 1884, without username, password as well as last will testament topic and payload specified.

    displayId configures in Orchestrator's config and should be provided in init() function.

    decrementCallSequenceOnArrival it is a field which allow Libpis to manipulate with callSequenceNumber handling. It is an optional field and by default set as true.

    preview configures in Orchestrator's config and should be provided in init() function.

    We can subscribe on updates method and receive all data which Libpis handles or subscribe specified property localtime as example, to receive only localtime updates.

    <body>
    <script>
    const externalConfig = {
    hostname: "192.168.1.2",
    port: 1884,
    username: "something",
    password: "secret",
    lastWillTopic: "pis/0/app/WebApp/lwt",
    lastWillPayload: "string",
    lastWillRetain: true,
    lastWillQos: 2,
    };
    window.luminator.pis.init({externalConfig, displayId, decrementCallSequenceOnArrival, preview});
    window.luminator.pis.client.updates().subscribe({
    console.log("Got an update from libpis:", state);
    });
    window.luminator.pis.client.state.localTime.subscribe((localTime) =>
    console.log("Got a localtime update from Libpis", localTime),
    );
    </script>
    </body>

    The fields of state object can be found from here: https://docs.suite.luminator.com/libpis/interfaces/NormalizedState.html