public final class MqttServer extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close(String clientId)
服务端主动断开连接
|
static MqttServerCreator |
create() |
boolean |
disconnect(String clientId)
服务端主动断开 mqtt 连接,mqtt5.0
|
org.tio.core.ChannelContext |
getChannelContext(String clientId)
获取 ChannelContext
|
org.tio.server.TioServerConfig |
getServerConfig()
获取 ServerTioConfig
|
MqttServerCreator |
getServerCreator()
获取 mqtt 配置
|
org.tio.server.TioServer |
getTioServer()
获取 TioServer
|
MqttWebServer |
getWebServer()
获取 http、websocket 服务
|
boolean |
publish(String clientId,
String topic,
ByteBuffer payload)
发布消息
|
boolean |
publish(String clientId,
String topic,
ByteBuffer payload,
boolean retain)
发布消息
|
boolean |
publish(String clientId,
String topic,
ByteBuffer payload,
net.dreamlu.iot.mqtt.codec.MqttQoS qos)
发布消息
|
boolean |
publish(String clientId,
String topic,
ByteBuffer payload,
net.dreamlu.iot.mqtt.codec.MqttQoS qos,
boolean retain)
发布消息
|
boolean |
publishAll(String topic,
byte[] payload)
发布消息给所以的在线设备
|
boolean |
publishAll(String topic,
byte[] payload,
boolean retain)
发布消息给所以的在线设备
|
boolean |
publishAll(String topic,
byte[] payload,
net.dreamlu.iot.mqtt.codec.MqttQoS qos)
发布消息
|
boolean |
publishAll(String topic,
byte[] payload,
net.dreamlu.iot.mqtt.codec.MqttQoS qos,
boolean retain)
发布消息给所以的在线设备
|
boolean |
publishAll(String topic,
ByteBuffer payload)
发布消息给所以的在线设备
|
boolean |
publishAll(String topic,
ByteBuffer payload,
boolean retain)
发布消息给所以的在线设备
|
boolean |
publishAll(String topic,
ByteBuffer payload,
net.dreamlu.iot.mqtt.codec.MqttQoS qos)
发布消息
|
boolean |
publishAll(String topic,
ByteBuffer payload,
net.dreamlu.iot.mqtt.codec.MqttQoS qos,
boolean retain)
发布消息给所以的在线设备
|
org.tio.utils.timer.TimerTask |
schedule(Runnable command,
long delay)
添加定时任务
|
org.tio.utils.timer.TimerTask |
schedule(Runnable command,
long delay,
Executor executor)
添加定时任务
|
org.tio.utils.timer.TimerTask |
scheduleOnce(Runnable command,
long delay)
添加定时任务,注意:如果抛出异常,会终止后续任务,请自行处理异常
|
org.tio.utils.timer.TimerTask |
scheduleOnce(Runnable command,
long delay,
Executor executor)
添加定时任务,注意:如果抛出异常,会终止后续任务,请自行处理异常
|
boolean |
sendToClient(String topic,
Message message)
发送消息到客户端
|
boolean |
start()
启动服务
|
boolean |
stop()
停止服务
|
public static MqttServerCreator create()
public org.tio.server.TioServer getTioServer()
public MqttWebServer getWebServer()
public org.tio.server.TioServerConfig getServerConfig()
public MqttServerCreator getServerCreator()
public boolean publish(String clientId, String topic, ByteBuffer payload)
clientId - clientIdtopic - topicpayload - 消息体public boolean publish(String clientId, String topic, ByteBuffer payload, net.dreamlu.iot.mqtt.codec.MqttQoS qos)
clientId - clientIdtopic - topicpayload - 消息体qos - MqttQoSpublic boolean publish(String clientId, String topic, ByteBuffer payload, boolean retain)
clientId - clientIdtopic - topicpayload - 消息体retain - 是否在服务器上保留消息public boolean publish(String clientId, String topic, ByteBuffer payload, net.dreamlu.iot.mqtt.codec.MqttQoS qos, boolean retain)
clientId - clientIdtopic - topicpayload - 消息体qos - MqttQoSretain - 是否在服务器上保留消息public boolean publishAll(String topic, byte[] payload)
topic - topicpayload - 消息体public boolean publishAll(String topic, ByteBuffer payload)
topic - topicpayload - 消息体public boolean publishAll(String topic, byte[] payload, net.dreamlu.iot.mqtt.codec.MqttQoS qos)
topic - topicpayload - 消息体qos - MqttQoSpublic boolean publishAll(String topic, ByteBuffer payload, net.dreamlu.iot.mqtt.codec.MqttQoS qos)
topic - topicpayload - 消息体qos - MqttQoSpublic boolean publishAll(String topic, byte[] payload, boolean retain)
topic - topicpayload - 消息体retain - 是否在服务器上保留消息public boolean publishAll(String topic, ByteBuffer payload, boolean retain)
topic - topicpayload - 消息体retain - 是否在服务器上保留消息public boolean publishAll(String topic, byte[] payload, net.dreamlu.iot.mqtt.codec.MqttQoS qos, boolean retain)
topic - topicpayload - 消息体qos - MqttQoSretain - 是否在服务器上保留消息public boolean publishAll(String topic, ByteBuffer payload, net.dreamlu.iot.mqtt.codec.MqttQoS qos, boolean retain)
topic - topicpayload - 消息体qos - MqttQoSretain - 是否在服务器上保留消息public boolean sendToClient(String topic, Message message)
topic - topicmessage - Messagepublic org.tio.utils.timer.TimerTask schedule(Runnable command, long delay)
command - runnabledelay - delaypublic org.tio.utils.timer.TimerTask schedule(Runnable command, long delay, Executor executor)
command - runnabledelay - delayexecutor - 用于自定义线程池,处理耗时业务public org.tio.utils.timer.TimerTask scheduleOnce(Runnable command, long delay)
command - runnabledelay - delaypublic org.tio.utils.timer.TimerTask scheduleOnce(Runnable command, long delay, Executor executor)
command - runnabledelay - delayexecutor - 用于自定义线程池,处理耗时业务public boolean disconnect(String clientId)
public org.tio.core.ChannelContext getChannelContext(String clientId)
clientId - clientIdpublic void close(String clientId)
clientId - clientIdpublic boolean start()
public boolean stop()
Copyright © 2023. All rights reserved.