Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bretambrose committed Dec 3, 2024
1 parent c615947 commit ec74ca5
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 0 deletions.
65 changes: 65 additions & 0 deletions src/main/java/software/amazon/awssdk/crt/iot/MqttRequest.java
Original file line number Diff line number Diff line change
@@ -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<MqttRequestResponsePath> responsePaths = new ArrayList<>();
private ArrayList<String> 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();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}

0 comments on commit ec74ca5

Please sign in to comment.