/* 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 DISCONNECT message from client to broker /// public class MqttMsgDisconnect : MqttMsgBase { /// /// Constructor /// public MqttMsgDisconnect() { this.type = MQTT_MSG_DISCONNECT_TYPE; } /// /// Parse bytes for a DISCONNECT message /// /// First fixed header byte /// Channel connected to the broker /// DISCONNECT message instance public static MqttMsgDisconnect Parse(byte fixedHeaderFirstByte, IMqttNetworkChannel channel) { MqttMsgDisconnect msg = new MqttMsgDisconnect(); // get remaining length and allocate buffer int remainingLength = MqttMsgBase.decodeRemainingLength(channel); // NOTE : remainingLength must be 0 return msg; } public override byte[] GetBytes() { byte[] buffer = new byte[2]; int index = 0; // first fixed header byte buffer[index++] = (MQTT_MSG_DISCONNECT_TYPE << MSG_TYPE_OFFSET); buffer[index++] = 0x00; return buffer; } } }