Java Setting Durable Requests

If requests are sent without being set as durable while the device isn't connected to GameSparks due to connection problems, they will timeout. If those requests were set to durable before being sent off, they will be queued and resent once the device regains connection to the backend.

Using the SetDurable Parameter? For more details on how and when to use the SetDurable parameter, see here.

To set a request as durable in Java you'll need to instantiate the request first, then set it as durable. This is because the setDurable method does not return the request.

Here's how to instantiate and set a request as durable:

1. Import the request that you're instantiating. For our example we're instantiating a LogEventRequest:

import com.gamesparks.sdk.api.autogen.GSRequestBuilder.LogEventRequest;

2. Instantiate the request:

LogEventRequest req = GSAndroidPlatform.gs().getRequestBuilder().createLogEventRequest();

3. Set durable true:

req.setDurable(true);

4. Send the request:

req.send(new GSEventConsumer<GSResponseBuilder.LogEventResponse>() {
            @Override
            public void onEvent(GSResponseBuilder.LogEventResponse logEventResponse) {

            }
        });

This can be done for every request in the GameSparks API library.

Did this page help you? Please enter your feedback below. For questions about using this part of the platform, please contact support here