Class DataRequestResponder

java.lang.Object
net.swofty.redisapi.api.requests.DataRequestResponder

public class DataRequestResponder extends Object
  • Field Details

  • Constructor Details

    • DataRequestResponder

      protected DataRequestResponder(Function<org.json.JSONObject, org.json.JSONObject> callback)
  • Method Details

    • respond

      public org.json.JSONObject respond(org.json.JSONObject request)
      Respond to a received request. This method should not be handled manually, the server's listener calls this method automatically.
      Parameters:
      request - the request data as a JSONObject
      Returns:
      the response data as a JSONObject
    • create

      public static DataRequestResponder create(String key, Function<org.json.JSONObject, org.json.JSONObject> callback)
      Create a responder to a data request, so when a data request with a specified key gets sent to this server, it'll respond back.
      Parameters:
      key - the server's unique key.
      callback - callback function, the input is the request data as a JSONObject and the output must be your response data as a JSONObject.
      Returns:
      the responder you just created.
    • get

      public static DataRequestResponder get(String key)
      Get a responder by its unique key.
      Parameters:
      key - The responder's unique key.
      Returns:
      The DataRequestResponder which is stored with that unique key.