waitForQueryResponse

Common code to wait for a query response.

Merely spins and monitors the shared TwitchPlugin.responseBucket

associative array for when a response has arrived, and then returns it.

Times out after a hardcoded Timeout.httpGET if nothing was received.

Note: Must be called from inside a Fiber.

version(TwitchSupport && WithTwitchPlugin)
package
waitForQueryResponse
(,
const int id
)

Parameters

plugin TwitchPlugin

The current TwitchPlugin.

id int

Numerical ID to use as key when storing the response in the bucket AA.

Return Value

Type: auto

A QueryResponse as constructed by other parts of the program.

Examples

immutable id = plugin.responseBucket.uniqueKey;
immutable url = "https://api.twitch.tv/helix/users?login=zorael";
plugin.getNextWorkerTid().send(
    id,
    url,
    plugin.transient.authorizationBearer,
    HTTPVerb.get,
    cast(ubyte[])null,
    string.init);

delay(plugin, plugin.transient.approximateQueryTime.msecs, yield: true);
immutable response = waitForQueryResponse(plugin, id, url);
// response.str is the response body
assert(id !in plugin.responseBucket);