本文整理汇总了Java中io.netty.handler.codec.mqtt.MqttPublishVariableHeader类的典型用法代码示例。如果您正苦于以下问题:Java MqttPublishVariableHeader类的具体用法?Java MqttPublishVariableHeader怎么用?Java MqttPublishVariableHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MqttPublishVariableHeader类属于io.netty.handler.codec.mqtt包,在下文中一共展示了MqttPublishVariableHeader类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doMessage
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; //导入依赖的package包/类
public MqttMessage doMessage(MqttMessage msg) {
logger.debug("MQTT PUBACK");
MqttPublishVariableHeader publishVariableHeader = (MqttPublishVariableHeader) msg.variableHeader();
int packetId = publishVariableHeader.packetId();
ManagerHandler.removeSendedMessage(packetId);
return null;
}
示例2: createMqttPublishMsg
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; //导入依赖的package包/类
private MqttPublishMessage createMqttPublishMsg(DeviceSessionCtx ctx, String topic, JsonElement json) {
MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, MqttQoS.AT_LEAST_ONCE, false,
0);
MqttPublishVariableHeader header = new MqttPublishVariableHeader(topic, ctx.nextMsgId());
ByteBuf payload = ALLOCATOR.buffer();
payload.writeBytes(GSON.toJson(json).getBytes(UTF8));
return new MqttPublishMessage(mqttFixedHeader, header, payload);
}
示例3: send
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; //导入依赖的package包/类
protected void send(int messageId, String topicName, int qosLevel, boolean isRetain, ByteBuf payload, int deliveryCount) {
boolean redelivery = qosLevel == 0 ? false : (deliveryCount > 0);
MqttFixedHeader header = new MqttFixedHeader(MqttMessageType.PUBLISH, redelivery, MqttQoS.valueOf(qosLevel), isRetain, 0);
MqttPublishVariableHeader varHeader = new MqttPublishVariableHeader(topicName, messageId);
MqttMessage publish = new MqttPublishMessage(header, varHeader, payload);
sendToClient(publish);
}
示例4: publish
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; //导入依赖的package包/类
public static MqttPublishMessage publish(IMessage message, boolean isDup) {
MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, isDup, message.qos(),
message.isRetain(), 7 + message.message().length);
MqttPublishVariableHeader variableHeader = new MqttPublishVariableHeader(message.topicName(), message.id());
ByteBuf buf = PooledByteBufAllocator.DEFAULT.buffer(message.message().length);
return new MqttPublishMessage(fixedHeader, variableHeader, buf.writeBytes(message.message()));
}
示例5: createPublishMessage
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; //导入依赖的package包/类
private MqttPublishMessage createPublishMessage() {
MqttFixedHeader mqttFixedHeader =
new MqttFixedHeader(MqttMessageType.PUBLISH, false, MqttQoS.AT_LEAST_ONCE, true, 0);
MqttPublishVariableHeader mqttPublishVariableHeader = new MqttPublishVariableHeader(MQTT_TOPIC, 1);
ByteBuf payload = ALLOCATOR.buffer();
payload.writeBytes(MQTT_MESSAGE.getBytes(CharsetUtil.UTF_8));
return new MqttPublishMessage(mqttFixedHeader, mqttPublishVariableHeader, payload);
}
示例6: createPublishMessage
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; //导入依赖的package包/类
private MqttPublishMessage createPublishMessage() {
MqttFixedHeader mqttFixedHeader =
new MqttFixedHeader(MqttMessageType.PUBLISH, false, MqttQoS.AT_LEAST_ONCE, true, 0);
MqttPublishVariableHeader mqttPublishVariableHeader = new MqttPublishVariableHeader(MQTT_TOPIC, 1);
ByteBuf payload = ALLOCATOR.buffer();
payload.writeBytes(MQTT_MESSAGE.getBytes(CharsetUtil.UTF_8));
return new MqttPublishMessage(mqttFixedHeader, mqttPublishVariableHeader, payload);
}
示例7: addRetainMessage
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; //导入依赖的package包/类
/**
* Add retain message for the topic name
* Retain id will be generated
*
* @param topicLevels Topic Levels
* @param msg Retain Message
* @return Retain Id
*/
int addRetainMessage(List<String> topicLevels, Message<MqttPublishVariableHeader, MqttPublishPayload> msg);
示例8: getMatchRetainMessages
import io.netty.handler.codec.mqtt.MqttPublishVariableHeader; //导入依赖的package包/类
/**
* Get all retain messages the topic name
*
* @param topicLevels Topic Levels
* @return List of Retain Message
*/
List<Message<MqttPublishVariableHeader, MqttPublishPayload>> getMatchRetainMessages(List<String> topicLevels);