/* M2Mqtt - MQTT Client Library for .Net Copyright (c) 2014, Paolo Patierno, All rights reserved. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. */ namespace uPLibrary.Networking.M2Mqtt.Messages { /// /// Class for PINGREQ message from client to broker /// public class MqttMsgPingReq : MqttMsgBase { /// /// Constructor /// public MqttMsgPingReq() { this.type = MQTT_MSG_PINGREQ_TYPE; } public override byte[] GetBytes() { byte[] buffer = new byte[2]; int index = 0; // first fixed header byte buffer[index++] = (MQTT_MSG_PINGREQ_TYPE << MSG_TYPE_OFFSET); buffer[index++] = 0x00; return buffer; } /// /// Parse bytes for a PINGREQ message /// /// First fixed header byte /// Channel connected to the broker /// PINGREQ message instance public static MqttMsgPingReq Parse(byte fixedHeaderFirstByte, IMqttNetworkChannel channel) { MqttMsgPingReq msg = new MqttMsgPingReq(); // already know remaininglength is zero (MQTT specification), // so it isn't necessary to read other data from socket int remainingLength = MqttMsgBase.decodeRemainingLength(channel); return msg; } } }