-
Notifications
You must be signed in to change notification settings - Fork 12
Quick start
BasRemoteClient implements the IDisposable
interface. This means that you can use using operator with an instance of this class. On disposing client closes WebSocket connection and terminate BAS process. Quick example for setup:
using System;
using System.Threading.Tasks;
using BASRemote;
namespace BASRemoteExample
{
internal static class Program
{
private static async Task Main()
{
var options = new Options {ScriptName = "AnyScriptName"};
using (var client = new BasRemoteClient(options))
{
await client.Start();
// Perform any actions here.
Console.ReadKey();
}
}
}
}
Options class 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.WorkingDirectory
), then data folder with the engine and scripts will be placed next to your executable file.
You can work with сlient only after it will be initialized. I.e you must call Start()
before run functions, create threads etc.
Start()
method contains two main steps:
- Starting the engine service (Download, unzip and run BAS)
- Starting the socket service (Connect to WebSocket and other)
In order to know about each stage, you can use events:
OnEngineDownloadStarted
OnEngineDownloadEnded
OnEngineExtractStarted
OnEngineExtractEnded
But these operations 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.
Remember that if you try to execute a function or send a message without starting the client, the ClientNotStartedException
will be raised.