Asynchronous HTTP calls

Function Returns Description
HttpGetRequestAsync(url, messageId) void Issues a fire-and-forget HTTP GET to the given URL. The eventual response (or failure) is queued onto _scriptAsyncResponses tagged with the given message id, so script code can poll for it asynchronously. On exception, the response is queued with code -100 and the exception message as text.
CallVindralApiAsync(endpointPath, messageId) void Calls the Vindral Live API with the specified endpoint path. The base URL and API key are retrieved from application settings.
AddApiCommandToQueue(command) void Enqueues an HTTP API command string into the project's pending request queue so it is processed on the next API tick.

HttpGetRequestAsync(url, messageId)

Issues a fire-and-forget GET. The eventual response is queued onto the script-async-response channel and delivered to the script as an OnComposerMessage(json) callback on a future render frame:

const REQ_GET_TEMPERATURE = "get-temperature";

function OnRenderFrame() {
    if (frameCount == 60)
        Project.HttpGetRequestAsync("https://api.example.com/temp", REQ_GET_TEMPERATURE);
}

function OnComposerMessage(json) {
    var msg = JSON.parse(json);
    if (msg.MessageId == REQ_GET_TEMPERATURE) {
        Logger.Info("HTTP " + msg.ResponseCode + ": " + msg.ResponseText);
    }
}

OnComposerMessage receives a JSON-stringified HttpResponse:

Field Type Description
MessageId string Echo of the messageId you passed in.
ResponseCode int HTTP status code, or -100 if the request threw.
ResponseText string Response body (or exception message on -100).

CallVindralApiAsync(endpointPath, messageId)

Same response model, but issues an authenticated GET to the configured Vindral Live API. Reads VindralLiveApiBaseUrl and VindralLiveApiKey from settings; logs an error and skips if either is missing. The response arrives via OnComposerMessage.

AddApiCommandToQueue(command)

Enqueues a Composer HTTP API command string into the project's pending request queue, processed on the next API tick. Use this when you want to drive Composer's own API from inside a script without going over the network.

Project.AddApiCommandToQueue("/api/setproperty?targetname=Audio Mixer&property=Mute&value=true");