Package br.com.anteros.mqtt.core.server
Class MqttServer
- java.lang.Object
-
- br.com.anteros.mqtt.core.server.MqttServer
-
public final class MqttServer extends Object
mqtt 服务端- Author:
- L.cm
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose(String clientId)服务端主动断开连接static MqttServerCreatorcreate()org.tio.core.ChannelContextgetChannelContext(String clientId)获取 ChannelContextorg.tio.server.ServerTioConfiggetServerConfig()获取 ServerTioConfigMqttServerCreatorgetServerCreator()获取 mqtt 配置org.tio.server.TioServergetTioServer()获取 TioServerMqttWebServergetWebServer()获取 http、websocket 服务booleanpublish(String clientId, String topic, ByteBuffer payload)发布消息booleanpublish(String clientId, String topic, ByteBuffer payload, boolean retain)发布消息booleanpublish(String clientId, String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos)发布消息booleanpublish(String clientId, String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos, boolean retain)发布消息booleanpublish(org.tio.core.ChannelContext context, String clientId, String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos, boolean retain)发布消息booleanpublishAll(String topic, ByteBuffer payload)发布消息给所以的在线设备booleanpublishAll(String topic, ByteBuffer payload, boolean retain)发布消息给所以的在线设备booleanpublishAll(String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos)发布消息booleanpublishAll(String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos, boolean retain)发布消息给所以的在线设备booleanstart()启动服务booleanstop()停止服务
-
-
-
Method Detail
-
create
public static MqttServerCreator create()
-
getTioServer
public org.tio.server.TioServer getTioServer()
获取 TioServer- Returns:
- TioServer
-
getWebServer
public MqttWebServer getWebServer()
获取 http、websocket 服务- Returns:
- MqttWebServer
-
getServerConfig
public org.tio.server.ServerTioConfig getServerConfig()
获取 ServerTioConfig- Returns:
- the serverTioConfig
-
getServerCreator
public MqttServerCreator getServerCreator()
获取 mqtt 配置- Returns:
- MqttServerCreator
-
publish
public boolean publish(String clientId, String topic, ByteBuffer payload)
发布消息- Parameters:
clientId- clientIdtopic- topicpayload- 消息体- Returns:
- 是否发送成功
-
publish
public boolean publish(String clientId, String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos)
发布消息- Parameters:
clientId- clientIdtopic- topicpayload- 消息体qos- MqttQoS- Returns:
- 是否发送成功
-
publish
public boolean publish(String clientId, String topic, ByteBuffer payload, boolean retain)
发布消息- Parameters:
clientId- clientIdtopic- topicpayload- 消息体retain- 是否在服务器上保留消息- Returns:
- 是否发送成功
-
publish
public boolean publish(String clientId, String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos, boolean retain)
发布消息- Parameters:
clientId- clientIdtopic- topicpayload- 消息体qos- MqttQoSretain- 是否在服务器上保留消息- Returns:
- 是否发送成功
-
publish
public boolean publish(org.tio.core.ChannelContext context, String clientId, String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos, boolean retain)发布消息- Parameters:
context- ChannelContextclientId- clientIdtopic- topicpayload- 消息体qos- MqttQoSretain- 是否在服务器上保留消息- Returns:
- 是否发送成功
-
publishAll
public boolean publishAll(String topic, ByteBuffer payload)
发布消息给所以的在线设备- Parameters:
topic- topicpayload- 消息体- Returns:
- 是否发送成功
-
publishAll
public boolean publishAll(String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos)
发布消息- Parameters:
topic- topicpayload- 消息体qos- MqttQoS- Returns:
- 是否发送成功
-
publishAll
public boolean publishAll(String topic, ByteBuffer payload, boolean retain)
发布消息给所以的在线设备- Parameters:
topic- topicpayload- 消息体retain- 是否在服务器上保留消息- Returns:
- 是否发送成功
-
publishAll
public boolean publishAll(String topic, ByteBuffer payload, br.com.anteros.mqtt.codec.MqttQoS qos, boolean retain)
发布消息给所以的在线设备- Parameters:
topic- topicpayload- 消息体qos- MqttQoSretain- 是否在服务器上保留消息- Returns:
- 是否发送成功
-
getChannelContext
public org.tio.core.ChannelContext getChannelContext(String clientId)
获取 ChannelContext- Parameters:
clientId- clientId- Returns:
- ChannelContext
-
close
public void close(String clientId)
服务端主动断开连接- Parameters:
clientId- clientId
-
start
public boolean start()
启动服务- Returns:
- 是否启动
-
stop
public boolean stop()
停止服务- Returns:
- 是否停止
-
-