Skip to content

Commit

Permalink
Release of version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rongsaws committed Jul 8, 2016
1 parent 683ad63 commit e14223a
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 31 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ of your Maven project.
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
</dependencies>
```
Expand All @@ -88,7 +88,7 @@ The sample applications included with the SDK can also be installed using the fo
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java-samples</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
</dependencies>
```
Expand All @@ -101,9 +101,7 @@ include them to your library build path.
You will also need to add two libraries the SDK depends on:

* Jackson 2.x, including Jackson-core and Jackson-databind. [download instructions][jackson-download]
* Paho MQTT client for Java 1.0.x. [download instructions][paho-mqtt-java-download]
(Note: If you plan to use MQTT over WebSocket connections, use its development branch or snapshot builds here
https://repo.eclipse.org/content/repositories/paho-snapshots/.)
* Paho MQTT client for Java 1.1.x. [download instructions][paho-mqtt-java-download]

### Build the SDK from the GitHub Source
You can build both the SDK and its sample applications from the source
Expand Down
4 changes: 2 additions & 2 deletions aws-iot-device-sdk-java-samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<parent>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java-pom</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>
<artifactId>aws-iot-device-sdk-java-samples</artifactId>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
</dependencies>
<build>
Expand Down
9 changes: 2 additions & 7 deletions aws-iot-device-sdk-java-samples/samples-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java-samples</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
Expand All @@ -12,7 +12,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand All @@ -24,11 +24,6 @@
<artifactId>jackson-databind</artifactId>
<version>2.7.4</version>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>[1.0.2,)</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
4 changes: 2 additions & 2 deletions aws-iot-device-sdk-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java-pom</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
</parent>
<artifactId>aws-iot-device-sdk-java</artifactId>
<dependencies>
Expand Down Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>[1.0.2,)</version>
<version>[1.1.0,)</version>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,49 @@ public void unsubscribe(AWSIotTopic topic, long timeout) throws AWSIotException
}
}

public void dispatch(AWSIotMessage message) {
AWSIotTopic topic = subscriptions.get(message.getTopic());
if (topic != null) {
topic.onMessage(message);
} else {
LOGGER.warning("Unexpected message received from topic " + message.getTopic());
public boolean topicFilterMatch(String topicFilter, String topic) {
if (topicFilter == null || topic == null) {
return false;
}

String[] filterTokens = topicFilter.split("/");
String[] topicTokens = topic.split("/");
if (filterTokens.length > topicTokens.length) {
return false;
}

for (int i = 0; i < filterTokens.length; i++) {
if (filterTokens[i].equals("#")) {
// '#' must be the last character
return ((i + 1) == filterTokens.length);
}

if (!(filterTokens[i].equals(topicTokens[i]) || filterTokens[i].equals("+"))) {
return false;
}
}

return (filterTokens.length == topicTokens.length);
}

public void dispatch(final AWSIotMessage message) {
boolean matches = false;

for (String topicFilter : subscriptions.keySet()) {
if (topicFilterMatch(topicFilter, message.getTopic())) {
final AWSIotTopic topic = subscriptions.get(topicFilter);
scheduleTask(new Runnable() {
@Override
public void run() {
topic.onMessage(message);
}
});
matches = true;
}
}

if (!matches) {
LOGGER.warning("Unexpected message received from topic " + message.getTopic());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,8 @@ public void deliveryComplete(IMqttDeliveryToken arg0) {

@Override
public void messageArrived(String topic, MqttMessage arg1) throws Exception {
final AWSIotMessage message = new AWSIotMessage(topic, AWSIotQos.valueOf(arg1.getQos()), arg1.getPayload());

client.scheduleTask(new Runnable() {
@Override
public void run() {
client.dispatch(message);
}
});
AWSIotMessage message = new AWSIotMessage(topic, AWSIotQos.valueOf(arg1.getQos()), arg1.getPayload());
client.dispatch(message);
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.amazonaws</groupId>
<artifactId>aws-iot-device-sdk-java-pom</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>pom</packaging>
<name>AWS IoT Device SDK for Java</name>
<description>The AWS IoT Device SDK for Java provides Java APIs for devices to connect to AWS IoT service using the MQTT protocol. The SDK also provides support for AWS IoT specific features, such as Thing Shadow and Thing Shadow abstraction.</description>
Expand Down

0 comments on commit e14223a

Please sign in to comment.