public void write() { messageData.Add(header.encode()); writeMsgLength(); writeMessage(); byte[] data = messageData.ToArray(); try { mqttConnection.sendMessage(data); } catch { throw; } }