10#include <QAbstractSocket>
22 return asyncLauncher(std::bind(&DataSender::sendPackagePrivate,
this, array, target), await);
25bool QH::DataSender::sendPackagePrivate(QByteArray array,
void *target)
const {
26 auto ptr =
static_cast<QAbstractSocket*
>(target);
28 if (!(ptr && ptr->isValid() && ptr->isWritable())) {
29 qCritical() <<
"Send raw data error. Socket is invalid";
35 while (wrote < array.length() && ptr->isWritable()) {
36 wrote += ptr->write(array.mid(wrote, array.length()));
40 qCritical() <<
"Send raw data error. data not flushed";
44 if (array.size() != wrote) {
45 qCritical() <<
"Send raw data error. not all data writed";
The Async class This is bundle of async templates and async wrappers.
bool asyncLauncher(const Job &job, bool await=false, bool freaze=true) const
asyncLauncher This method invoke a job on the thread (using the asyncHandler method) of this object.
DataSender(QThread *thread)
bool sendData(const QByteArray &array, void *target, bool await=false) const
sendPackagePrivate This slot move send package to a main thread.
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...