/*
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.
*/
using System;
namespace uPLibrary.Networking.M2Mqtt.Messages
{
///
/// Class for PINGRESP message from client to broker
///
public class MqttMsgPingResp : MqttMsgBase
{
///
/// Constructor
///
public MqttMsgPingResp()
{
this.type = MQTT_MSG_PINGRESP_TYPE;
}
///
/// Parse bytes for a PINGRESP message
///
/// First fixed header byte
/// Channel connected to the broker
/// PINGRESP message instance
public static MqttMsgPingResp Parse(byte fixedHeaderFirstByte, IMqttNetworkChannel channel)
{
MqttMsgPingResp msg = new MqttMsgPingResp();
// 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;
}
public override byte[] GetBytes()
{
byte[] buffer = new byte[2];
int index = 0;
// first fixed header byte
buffer[index++] = (MQTT_MSG_PINGRESP_TYPE << MSG_TYPE_OFFSET);
buffer[index++] = 0x00;
return buffer;
}
}
}