The ServiceRequester object provides a layer for catching and handling 503 Service Unavailable HTTP status codes. These errors can occur when our services are temporarily disabled or taken down for maintenance. If a service is disabled the ServiceRequester object will:
See the example for a more detailed description.
You can get the ServiceRequester object from the service property on our service managers or from the TurbulenzServices.getService function.
Supported services
The current supported services are:
The ServiceRequester objects are shared for each instance of these managers.
Example
leaderboardManager.service.onServiceUnavailable = function onServiceUnavailableFn() {
document.write(this.serviceName + ' service is unavailable');
};
leaderboardManager.service.onServiceAvailable = function onServiceUnavailableFn() {
document.write(this.serviceName + ' service is available');
};
var leaderboardsSetCB = function leaderboardsSetCBFn(key, score, newBest, bestScore)
{
document.write('Score has been set');
}
var errorCallbackFn = function leaderboardsSetErrorCBFn(msg, status)
{
document.write('HTTP Error ' + status);
};
leaderboardManager.set(key, score, leaderboardsSetCB, errorCallbackFn);
If the service is down for a long period (for example 10 minutes) then you should expect the following:
Summary
A JavaScript string. The name of the service. This is for developers and should not be directly displayed.
Syntax
var serviceName = ServiceRequester.serviceName;
Summary
A JavaScript boolean. True, if the service is running, false, if the service is unavailable.
Syntax
if (!serviceRequester.running)
{
renderServiceUnavailable();
}
Note
If this is true it does not mean that the service will still be available when a request to the service is made.
Summary
A JavaScript function. This function is called when a service is re-enabled.
Syntax
serviceRequester.onServiceAvailable = function onServiceAvailableFn() {
Utilties.log(this.serviceName + ' is available');
};