65 lines
2.0 KiB
C#
65 lines
2.0 KiB
C#
/*
|
|
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
|
|
{
|
|
/// <summary>
|
|
/// Class for DISCONNECT message from client to broker
|
|
/// </summary>
|
|
public class MqttMsgDisconnect : MqttMsgBase
|
|
{
|
|
/// <summary>
|
|
/// Constructor
|
|
/// </summary>
|
|
public MqttMsgDisconnect()
|
|
{
|
|
this.type = MQTT_MSG_DISCONNECT_TYPE;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Parse bytes for a DISCONNECT message
|
|
/// </summary>
|
|
/// <param name="fixedHeaderFirstByte">First fixed header byte</param>
|
|
/// <param name="channel">Channel connected to the broker</param>
|
|
/// <returns>DISCONNECT message instance</returns>
|
|
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;
|
|
}
|
|
}
|
|
}
|