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

You can send custom messages to your script using BasRemoteClient. It's very useful if you want to perform actions like:

  • Retrieve results/logs.
  • Set/get global variables.
  • Show/hide browsers. and other different actions.

If you want to send message and perform any action on result of this message, you can use SendAsync() method. It contains also many overrides with different arguments, so you can create any logic as you want. With this method you can pass custom callback for message response and perform any actions with this. You can also use SendAndWaitAsync() to do this using Task class and await keyword. In this case response of your message will be contains in task result.

Take a look at examples.

Send message and perform action

// Set global variable with name 'TEST_VARIABLE' and value 'Hello'.
client.SendAsync("set_global_variable", new Params {
    ["name"] = "TEST_VARIABLE", 
    ["value"] = "Hello"
}, () => {
    // Retrieve actual variable value.
    client.SendAsync("get_global_variable", new Params {
        ["name"] = "TEST_VARIABLE"
    }, variable => {
        // Print the value.
        Console.WriteLine(variable);
    });
});

Send message and wait for result

// Set global variable with name 'TEST_VARIABLE' and value 'Hello'.
await client.SendAndWaitAsync("set_global_variable", new Params {
    ["name"] = "TEST_VARIABLE", 
    ["value"] = "Hello"
});

// Retrieve actual variable value.
var variable = await client.SendAndWaitAsync("get_global_variable", new Params {
    ["name"] = "TEST_VARIABLE"
});

// Print the value.
Console.WriteLine(variable);

Just send message

Among other options, you can just send a custom message. For example, if you want to show the database manager window, you can run the following code:

client.Send("show_database_manager");

After sending this message, you will see a manager window.

Clone this wiki locally