public final class MqttServer extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
void |
close(String clientId)
服务端主动断开连接
|
static MqttServerCreator |
create() |
org.tio.core.ChannelContext |
getChannelContext(String clientId)
获取 ChannelContext
|
org.tio.server.ServerTioConfig |
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,
MqttQoS qos)
发布消息
|
boolean |
publish(String clientId,
String topic,
ByteBuffer payload,
MqttQoS qos,
boolean retain)
发布消息
|
boolean |
publishAll(String topic,
ByteBuffer payload)
发布消息给所以的在线设备
|
boolean |
publishAll(String topic,
ByteBuffer payload,
boolean retain)
发布消息给所以的在线设备
|
boolean |
publishAll(String topic,
ByteBuffer payload,
MqttQoS qos)
发布消息
|
boolean |
publishAll(String topic,
ByteBuffer payload,
MqttQoS qos,
boolean retain)
发布消息给所以的在线设备
|
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.ServerTioConfig 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, 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, MqttQoS qos, boolean retain)
clientId - clientIdtopic - topicpayload - 消息体qos - MqttQoSretain - 是否在服务器上保留消息public boolean publishAll(String topic, ByteBuffer payload)
topic - topicpayload - 消息体public boolean publishAll(String topic, ByteBuffer payload, MqttQoS qos)
topic - topicpayload - 消息体qos - MqttQoSpublic boolean publishAll(String topic, ByteBuffer payload, boolean retain)
topic - topicpayload - 消息体retain - 是否在服务器上保留消息public boolean publishAll(String topic, ByteBuffer payload, MqttQoS qos, boolean retain)
topic - topicpayload - 消息体qos - MqttQoSretain - 是否在服务器上保留消息public boolean sendToClient(String topic, Message message)
topic - topicmessage - Messagepublic org.tio.core.ChannelContext getChannelContext(String clientId)
clientId - clientIdpublic void close(String clientId)
clientId - clientIdpublic boolean start()
public boolean stop()
Copyright © 2022. All rights reserved.