Skip to content

Conversation

@Maploop
Copy link
Contributor

@Maploop Maploop commented Dec 1, 2025

Example DataRequest usage:

import net.swofty.redisapi.api.requests.DataRequest;
import net.swofty.redisapi.api.requests.DataRequestResponder;
import org.json.JSONObject;

public class Example {
    public void sendDataRequest() {
        JSONObject requestData = new JSONObject()
                .put("data key", "data value");

        DataRequest req = new DataRequest("filterID", "key", requestData);

        req.await().thenAccept(response -> {
            if (response.data() == null) {
                // Timed out
                return;
            }

            // Use data
            response.data();
            response.latency();
        });
    }

    public void registerResponder() {
        DataRequestResponder.create("key", (request) -> {
            JSONObject response = new JSONObject();
            response.put("data to send back", "anything");
            return response;
        });
    }
}

@Swofty-Developments Swofty-Developments merged commit 9341ecd into Swofty-Developments:master Dec 1, 2025
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants