#include "clientprotocol.h" #include #include #include namespace ClientProtocol { Header::Header() { reset(); } bool Header::isValid() const { if (sizeof (*this) != 4) { return false; } return true; } void Header::reset() { size = 0; command = 0; triggerCommnad = 0; } Package::Package() { reset(); } bool Package::isValid() const { if (!hdr.isValid()) { return false; } if (data.size() && hdr.command != data.at(0)) { return false; } return hdr.size == static_cast (data.size()); } QByteArray Package::toBytes() const { QByteArray res; res.append(reinterpret_cast(const_cast(&hdr)), sizeof (hdr)); res.append(data); return res; } void Package::reset() { hdr.reset(); data.clear(); } bool initClientProtockol() { return true; } }