Skip to content
CheshireCaat edited this page Feb 25, 2020 · 3 revisions

Setting up the client instance

Before you begin, you need to initialize the client using the start() method. At the same time, remember to execute the close() method after completing the work so that the connection to the script is always interrupted.

const BasRemoteClient = require('bas-remote-node');

async function main() {
    const client = new BasRemoteClient({scriptName: 'TestRemoteControl'});

    // Initialize script (Required)
    await client.start();

    // Permorm any actions here

    // Close client connection
    await client.close();
}

main();

Options object in client constructor contains properties that must be specified for working.

The name of the script is required. Login and password can not be specified only if the script is free and everyone can access it. If you do not change the working directory (options.workingDir), then data folder with the engine and scripts will be placed next to your executable file.

Client launch

start() method contains two main steps:

  • Starting the engine service (Download, unzip and run BAS)
  • Starting the socket service (Connect to WebSocket and other)

But engine initialization are performed only if the version of the BAS engine or the script itself has changed. That is, it usually takes less than 3-5 seconds to start the client.

Clone this wiki locally