You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
constBasRemoteClient=require('bas-remote-node');asyncfunctionmain(){constclient=newBasRemoteClient({scriptName: 'TestRemoteControl'});// Initialize script (Required)awaitclient.start();// Permorm any actions here// Close client connectionawaitclient.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.