waitForQueryResponse

Common code to wait for a query response.

Merely spins and monitors the shared bucket 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 = getUniqueNumericalID(plugin.bucket);
immutable url = "https://api.twitch.tv/helix/users?login=zorael";
plugin.persistentWorkerTid.send(id, url, plugin.authorizationBearer);

delay(plugin, plugin.approximateQueryTime.msecs, Yes.yield);
immutable response = waitForQueryResponse(plugin, id, url);
// response.str is the response body

Meta