Java and Android SMQ Client Library and Example
SMQ, based on the publish - subscribe pattern, provides features similar to other pub/sub protocols such as MQTT. However, SMQ extends the pub/sub pattern with additional features such as one-to-one messaging and sender's address, features typically required in device management.
The Java SMQ client library is designed for standard Java and Android.
Note that the SMQ protocol supports both non secure and secure (TLS) connections, however, the Java SMQ client library is designed to operate only over a secure TLS connection. The TLS connection used by Java SMQ is managed by the Java platform's TLS functionality.
Compiling the Included Java Swing Example
This example is designed for Swing and. An Android example is also provided (see below).
You may include the SMQ Java code in your Java build, but do not include the file RTL/SMQ/AndroidSMQ.java since this file is designed for Android.
You may compile and run the SMQ LED example on the command line as follows:
javac LedSMQ.java java LedSMQ
The Swing example connects to the public SMQ test broker. You may control any of the connected devices, or you can run a simulated device by using the online device C example. Note that the Swing example also opens a browser window and redirects the browser to the LED example's HTML5 UI. This makes it easy for you to see how the Swing UI example can be synchronized in real time with the HTML5 UI example.
See the SMQ LED example's tutorial for more information on how this example works.
Compiling for Android
You may include the SMQ java code in your Android build, but do not include the file RTL/SMQ/SwingSMQ.java since this file is designed for Swing.
SMQ Library Source Code
The SMQ Java library can be found in RTL/SMQ. Depending on what environment you are building for, delete RTL/SMQ/AndroidSMQ.java or RTL/SMQ/SwingSMQ.java.
Example Source Code
- LedSMQ.java: the Swing LED example.
- org/json: the JSON library used by LedSMQ.java.
- eu/hansolo/steelseries: provides LED UI for LedSMQ.java.
Note: the Java SMQ library is not using any of the above and you should only include RTL/SMQ in your own build.
The source code is released under the Eclipse Public License - V 2.0: https://www.eclipse.org/legal/epl-v20.html
You may compile a Program licensed under the EPL without modification and commercially license the result in accordance with the terms of the EPL.
This Source Code may also be made available under the following Secondary Licenses when the conditions for such availability set forth in the Eclipse Public License, v. 2.0 are satisfied: GNU General Public License, version 2.