From ec74ca5375e1a7c9d27790e3da488e4223e2d15b Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Mon, 2 Dec 2024 18:08:36 -0800 Subject: [PATCH] Checkpoint --- .../amazon/awssdk/crt/iot/MqttRequest.java | 65 +++++++++++++++++++ .../crt/iot/MqttRequestResponseClient.java | 4 ++ .../crt/iot/MqttRequestResponsePath.java | 42 ++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 src/main/java/software/amazon/awssdk/crt/iot/MqttRequest.java create mode 100644 src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponsePath.java diff --git a/src/main/java/software/amazon/awssdk/crt/iot/MqttRequest.java b/src/main/java/software/amazon/awssdk/crt/iot/MqttRequest.java new file mode 100644 index 000000000..3b4fb9c24 --- /dev/null +++ b/src/main/java/software/amazon/awssdk/crt/iot/MqttRequest.java @@ -0,0 +1,65 @@ +package software.amazon.awssdk.crt.iot; + +import java.util.ArrayList; + +public class MqttRequest { + + public static class MqttRequestBuilder { + + private MqttRequest request = new MqttRequest(); + + private MqttRequestBuilder() {} + + public MqttRequestBuilder withResponsePath(MqttRequestResponsePath path) { + request.responsePaths.add(path); + return this; + } + + public MqttRequestBuilder withSubscription(String topicFilter) { + request.subscriptions.add(topicFilter); + return this; + } + + public MqttRequestBuilder withPublishTopic(String publishTopic) { + request.publishTopic = publishTopic; + return this; + } + + public MqttRequestBuilder withPayload(byte[] payload) { + request.payload = payload; + return this; + } + + + public MqttRequestBuilder withCorrelationToken(String correlationToken) { + request.correlationToken = correlationToken; + return this; + } + + public MqttRequest build() { + return new MqttRequest(request); + } + } + + private ArrayList responsePaths = new ArrayList<>(); + private ArrayList subscriptions = new ArrayList<>(); + private String publishTopic; + private String correlationToken; + private byte[] payload; + + private MqttRequest() { + } + + private MqttRequest(MqttRequest request) { + this.responsePaths.addAll(request.responsePaths); + this.subscriptions.addAll(request.subscriptions); + this.publishTopic = request.publishTopic; + this.correlationToken = request.correlationToken; + this.payload = request.payload; + } + + public MqttRequestBuilder builder() { + return new MqttRequestBuilder(); + } + +} diff --git a/src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponseClient.java b/src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponseClient.java index 778e34c4d..550ef1b62 100644 --- a/src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponseClient.java +++ b/src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponseClient.java @@ -35,6 +35,10 @@ public MqttRequestResponseClient(MqttClientConnection client, MqttRequestRespons )); } + public void submitRequest(MqttRequest request) { + + } + /** * Cleans up the native resources associated with this client. The client is unusable after this call */ diff --git a/src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponsePath.java b/src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponsePath.java new file mode 100644 index 000000000..2703554bd --- /dev/null +++ b/src/main/java/software/amazon/awssdk/crt/iot/MqttRequestResponsePath.java @@ -0,0 +1,42 @@ +package software.amazon.awssdk.crt.iot; + +import java.util.ArrayList; + +public class MqttRequestResponsePath { + + public static class MqttRequestResponsePathBuilder { + + private MqttRequestResponsePath path = new MqttRequestResponsePath(); + + private MqttRequestResponsePathBuilder() {} + + public MqttRequestResponsePathBuilder withResponseTopic(String responseTopic) { + path.responseTopic = responseTopic; + return this; + } + + public MqttRequestResponsePathBuilder withCorrelationTokenJsonPath(String correlationTokenJsonpath) { + path.correlationTokenJsonpath = correlationTokenJsonpath; + return this; + } + + public MqttRequestResponsePath build() { + return new MqttRequestResponsePath(path); + } + } + + private String responseTopic; + private String correlationTokenJsonpath; + + private MqttRequestResponsePath() { + } + + private MqttRequestResponsePath(MqttRequestResponsePath path) { + this.responseTopic = path.responseTopic; + this.correlationTokenJsonpath = path.correlationTokenJsonpath; + } + + public static MqttRequestResponsePathBuilder builder() { + return new MqttRequestResponsePathBuilder(); + } +}