1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-11-16 20:19:13 +01:00
doorlockd-mirror/doorlockd/client/network.h
Ralf Ramsauer d1d0d5b160 Fix QT quirk
So far, we used QT interfaces in a wrong way. QT is not thread safe, so
use its signal/slot concept and move network communication stuff to a
separate QThread.

Signed-off-by: Ralf Ramsauer <ralf@ramses-pyramidenbau.de>
2016-07-31 15:48:19 +02:00

38 lines
705 B
C++

#ifndef NETWORK_H
#define NETWORK_H
#include <string>
#include <boost/asio.hpp>
#include <QThread>
#include "../lib/clientmessage.h"
#include "../lib/logger.h"
class NetworkThread : public QThread {
Q_OBJECT
public:
NetworkThread(const std::string &hostname,
const unsigned short port);
private:
void run();
Logger &_l;
const std::string _hostname;
const unsigned short _port;
boost::asio::io_service _io_service;
const static std::string _subscription_command;
// The receive buffer length of the TCP socket
constexpr static int _SOCKET_BUFFERLENGTH = {2048};
signals:
void new_clientmessage(Clientmessage msg);
};
#endif