资源简介
1、利用apache-apollo-1.7.1创建MQTT broker
2、利用eclipse编写MQTT Server的JAVA代码
3、能够订阅(接收)和发布(发送)消息,带接收消息回显
4、该代码同时也可以作为客户端,只须做小小改动
代码片段和文件信息
package MQTT_Server;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
/*
import javax.swing.JButton;
import javax.swing.Jframe;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
*/
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttTopic;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
public class MQTT_Server extends Jframe {
private static final long serialVersionUID = 1L;
private JPanel panel_mqtt_center;
private JPanel panel_mqtt_center_publish;
private JPanel panel_mqtt_center_subscribe;
private JScrollPane panel_mqtt_top;
private JScrollPane panel_mqtt_bottom;
//private JPanel panel_pd_list;
private JButton button_pub;
private JButton button_sub;
private MqttClient client;
//private String host = “tcp://0.0.0.0:61613“;
private String host = “tcp://localhost:61613“;
private String userName = “admin“;
private String passWord = “password“;
public static final String TOPIC_BEAT = “beat“;
private MqttTopic topic;
private MqttMessage message;
JTextArea ta_pd_details;
JTextArea ta_pubta_sub;
JTextField tf_pd_findtf_pub_topictf_sub_topic;
JTable pd_table;
public MQTT_Server() {
try {
client = new MqttClient(host “Server“
new MemoryPersistence());
connect();
} catch (Exception e) {
e.printStackTrace();
}
this.settitle(“MQTT SERVER“);
Container container = this.getContentPane();
//container.setLayout(new java.awt.FlowLayout());
//top
String s2=“发布内容!!“;
ta_pub=new JTextArea(s2520);
panel_mqtt_top = new JScrollPane(ta_pub);
//center
panel_mqtt_center = new JPanel();
panel_mqtt_center.setLayout(new BorderLayout(1010));
panel_mqtt_center_publish = new JPanel();
panel_mqtt_center_publish.setLayout(new BorderLayout());
tf_pub_topic = new JTextField(“mytopic“);
button_pub = new JButton(“发布话题“);
panel_mqtt_center_publish.add(button_pubBorderLayout.EAST);
panel_mqtt_center_publish.add(tf_pub_topic);
panel_mqtt_center_subscribe = new JPanel();
panel_mqtt_center_subscribe.setLayout(new BorderLayout());
tf_sub_topic = new JTextField(“订阅主题“);
button_sub = new JButton(“订阅话题“);
panel_mqtt_center_subscribe.add(button_subBorderLayout.EAST);
panel_mqtt_center_subscribe.add(tf_sub_topic);
panel_mqtt_center.add(panel_mqtt_center_publishBorderLayout.NORTH);
panel_mqtt_center.add(panel_mqtt_center_subscribeBorderLayout.CENTER);
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 28110104 2016-12-06 11:56 MQTT_Server\apache-apollo-1.7.1-windows-distro.zip
文件 74 2017-05-16 11:34 MQTT_Server\mqtt_broker_create.bat
文件 40 2017-05-04 09:04 MQTT_Server\mqtt_broker_run.bat
文件 0 2017-04-18 15:24 MQTT_Server\MQTT_Server\.me
文件 172829 2017-05-19 16:55 MQTT_Server\MQTT_Server\.me
文件 20 2017-04-18 15:25 MQTT_Server\MQTT_Server\.me
文件 32 2017-04-18 15:25 MQTT_Server\MQTT_Server\.me
文件 250 2017-05-19 16:22 MQTT_Server\MQTT_Server\.me
文件 438 2017-04-18 15:25 MQTT_Server\MQTT_Server\.me
文件 250 2017-05-19 16:41 MQTT_Server\MQTT_Server\.me
文件 14923 2017-05-19 13:43 MQTT_Server\MQTT_Server\.me
文件 14851 2017-05-19 13:43 MQTT_Server\MQTT_Server\.me
文件 12591 2017-05-15 11:00 MQTT_Server\MQTT_Server\.me
文件 15473 2017-05-18 15:47 MQTT_Server\MQTT_Server\.me
文件 10205 2017-05-19 16:34 MQTT_Server\MQTT_Server\.me
文件 12591 2017-05-15 11:00 MQTT_Server\MQTT_Server\.me
文件 9898 2017-05-19 16:36 MQTT_Server\MQTT_Server\.me
文件 11119 2017-05-19 16:32 MQTT_Server\MQTT_Server\.me
文件 15480 2017-05-19 11:33 MQTT_Server\MQTT_Server\.me
文件 7465 2017-05-19 16:41 MQTT_Server\MQTT_Server\.me
文件 11032 2017-05-19 16:33 MQTT_Server\MQTT_Server\.me
文件 13544 2017-05-16 14:32 MQTT_Server\MQTT_Server\.me
文件 15167 2017-05-19 13:56 MQTT_Server\MQTT_Server\.me
文件 11755 2017-05-19 16:28 MQTT_Server\MQTT_Server\.me
文件 8517 2017-05-19 16:40 MQTT_Server\MQTT_Server\.me
文件 15490 2017-05-18 15:41 MQTT_Server\MQTT_Server\.me
文件 14851 2017-05-19 13:34 MQTT_Server\MQTT_Server\.me
文件 6593 2017-05-19 16:55 MQTT_Server\MQTT_Server\.me
文件 15453 2017-05-16 17:26 MQTT_Server\MQTT_Server\.me
文件 15450 2017-05-17 15:01 MQTT_Server\MQTT_Server\.me
............此处省略426个文件信息
相关资源
- 最新Android Studio3.0.1版收发MQTT消息
- mqtt详细
- mqtt + webScoket + apollo 具体
- android MQTT的使用及demo
- MQTT协议在Android的使用demo
- Android集成消息推送之MQTT
- send_mqtt.zip
- MQTT jar包 wmqtt.jar
- MQTT消息队列mosquitto的java方式实现客户
- org.eclipse.paho.client.mqttv3-1.0.1
- 基于Eclipse paho的MQTT java客户端
- MQTT JAVA jar包 wmqtt.jar
- MQTT相关java代码实现
- mqtt android使用源码
- org.eclipse.paho.android.service-1.1.0.jar
- mqtt的android端jar包
- mqtt jar包
- mqtt-spy 调试工具
- org.eclipse.paho.client.mqttv3-1.0.1.jar
- mqtt-xmeter-jar-with-dependencies.jar
- Android实现MQTT传输
- mqtt-client-1.7-uber.jar
- android 安卓mqtt 收发APP
- java 连接阿里云的mqtt服务(客户端源
- mqtt接收数据并保存
- apollo 源码需要的jar包
- Android MQTT Demo(阿里云)
- mqtt java客户端开发所使用的jar包
- moquette-mqtt源码
- mqtt 实时消息推送(android)
评论
共有 条评论