public static int EncodeUshort(MqttProperty mqttProperty, ushort data, byte[] buffer, int index) { buffer[index++] = (byte)mqttProperty; buffer[index++] = (byte)((data & 0xFF00) >> 8); buffer[index++] = (byte)(data & 0x00FF); return(index); }
public static void EncodeUTF8FromBuffer(MqttProperty mqttProperty, byte[] toEncode, byte[] buffer, ref int index) { buffer[index++] = (byte)mqttProperty; buffer[index++] = (byte)((toEncode.Length & 0xFF00) >> 8); buffer[index++] = (byte)(toEncode.Length & 0xFF); Array.Copy(toEncode, 0, buffer, index, toEncode.Length); index += toEncode.Length; }
public static byte[] EncodeArray(MqttProperty mqttProperty, byte[] buffer) { byte[] encodedBuffer = new byte[3 + buffer.Length]; Array.Copy(buffer, 0, encodedBuffer, 3, buffer.Length); encodedBuffer[0] = (byte)mqttProperty; encodedBuffer[1] = (byte)((buffer.Length & 0xFF00) >> 8); encodedBuffer[2] = (byte)(buffer.Length & 0xFF); return(encodedBuffer); }