Market Indices are the same for everyone so, in this scenario, we can serve all clients with a single task.
async Task<string> GetToken()
{
var envoytask = new Ape.EnvoyTask()
{
task_context = "marketrates",
send_offline_message = true,single_instance = false,
timeout = 5,persist_timeout = false
};
var client = new Ape.GetEnvoyTokenRequest()
{
reusable_minutes = 2,envoy_task = envoytask
};
var aperesp = await POST.Request(Ape.api_methods.get_envoy_token, client);
var tokenResp = JsonDeserialize(aperesp).Result;
return tokenResp.envoy_token;
}
With the following method the remote process performs a single HTTP request to serve all active clients.
async Task GetRatesTask()
{
while (true)
{
var rates = await Pricer.GetCoinbase();
var req = new InvokeEnvoyRequest
{
new_timeout = 5, message = rates,
task_id = TaskID
};
var aperesp = await POST.Request(Ape.api_methods.invoke_envoy, req);
}
}