Skip to content

Latest commit

 

History

History
38 lines (32 loc) · 863 Bytes

File metadata and controls

38 lines (32 loc) · 863 Bytes

jfinal mica-mqtt-server

使用

1. 添加依赖

<dependency>
	<groupId>net.dreamlu</groupId>
	<artifactId>mica-mqtt-server-jfinal-plugin</artifactId>
	<version>${最新版本}</version>
</dependency>

2. 删除 jfinal-demo 中的 slf4j-nop 依赖

3. 添加 slf4j-log4j12

<dependency>
	<groupId>org.slf4j</groupId>
	<artifactId>slf4j-log4j12</artifactId>
	<version>1.7.33</version>
</dependency>

4. 插件配置

MqttServerPlugin plugin = new MqttServerPlugin();
plugin.config(mqttServerCreator -> {
    // mqttServerCreator 上有很多方法,详见 mica-mqtt-core
    mqttServerCreator.port(1883).webPort(8083).websocketEnable(true);
});

5. 插件使用

// 更多方法可以直接使用 MqttServerKit 点出来
MqttServerKit.publish(String clientId, String topic, byte[] payload);