Java 类io.netty.handler.codec.mqtt.MqttPublishVariableHeader 实例源码

项目:iot-platform    文件:PubAckHandler.java   
public MqttMessage doMessage(MqttMessage msg) {
    logger.debug("MQTT PUBACK");

    MqttPublishVariableHeader publishVariableHeader = (MqttPublishVariableHeader) msg.variableHeader();
    int packetId = publishVariableHeader.packetId();
    ManagerHandler.removeSendedMessage(packetId);

    return null;
}
项目:iotplatform    文件:JsonMqttAdaptor.java   
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);
}
项目:activemq-artemis    文件:MQTTProtocolHandler.java   
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);
}
项目:lannister    文件:MqttMessageFactory.java   
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()));
}
项目:vertx-mqtt    文件:MqttServerBadClientTest.java   
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);
  }
项目:enmasse    文件:ConnectionTest.java   
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);
    }
项目:mithqtt    文件:SyncStorage.java   
/**
 * 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);
项目:mithqtt    文件:SyncStorage.java   
/**
 * Get all retain messages the topic name
 *
 * @param topicLevels Topic Levels
 * @return List of Retain Message
 */
List<Message<MqttPublishVariableHeader, MqttPublishPayload>> getMatchRetainMessages(List<String> topicLevels);