Java Code Examples for io.netty.handler.codec.mqtt.MqttMessageType#PUBREC

The following examples show how to use io.netty.handler.codec.mqtt.MqttMessageType#PUBREC . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MqttClientImpl.java    From vertx-mqtt with Apache License 2.0 6 votes vote down vote up
/**
 * Sends PUBREC packet to server
 *
 * @param publishMessage a PUBLISH message to acknowledge
 */
private void publishReceived(MqttPublishMessage publishMessage) {

  MqttFixedHeader fixedHeader =
    new MqttFixedHeader(MqttMessageType.PUBREC, false, AT_MOST_ONCE, false, 0);

  MqttMessageIdVariableHeader variableHeader =
    MqttMessageIdVariableHeader.from(publishMessage.messageId());

  io.netty.handler.codec.mqtt.MqttMessage pubrec = MqttMessageFactory.newMessage(fixedHeader, variableHeader, null);

  synchronized (this) {
    qos2inbound.put(publishMessage.messageId(), publishMessage);
  }
  this.write(pubrec);
}
 
Example 2
Source File: MqttMessageFactory.java    From lannister with Apache License 2.0 5 votes vote down vote up
public static MqttMessage pubrec(int messageId) {
	MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBREC, false, MqttQoS.AT_MOST_ONCE, false,
			2);
	MqttMessageIdVariableHeader variableHeader = MqttMessageIdVariableHeader.from(messageId);

	return new MqttMessage(fixedHeader, variableHeader);
}
 
Example 3
Source File: MessageUtil.java    From iot-mqtt with Apache License 2.0 4 votes vote down vote up
public static MqttMessage getPubRecMessage(int messageId){
    MqttFixedHeader fixedHeader = new MqttFixedHeader(MqttMessageType.PUBREC,false,MqttQoS.AT_MOST_ONCE,false,0);
    MqttMessage mqttMessage = new MqttMessage(fixedHeader,MqttMessageIdVariableHeader.from(messageId));
    return mqttMessage;
}
 
Example 4
Source File: PublishRecHandler.java    From joyqueue with Apache License 2.0 4 votes vote down vote up
@Override
public MqttMessageType type() {
    return MqttMessageType.PUBREC;
}
 
Example 5
Source File: MqttEndpointImpl.java    From vertx-mqtt with Apache License 2.0 3 votes vote down vote up
public MqttEndpointImpl publishReceived(int publishMessageId) {

    MqttFixedHeader fixedHeader =
      new MqttFixedHeader(MqttMessageType.PUBREC, false, MqttQoS.AT_MOST_ONCE, false, 0);
    MqttMessageIdVariableHeader variableHeader =
      MqttMessageIdVariableHeader.from(publishMessageId);

    io.netty.handler.codec.mqtt.MqttMessage pubrec = MqttMessageFactory.newMessage(fixedHeader, variableHeader, null);

    this.write(pubrec);

    return this;
  }