#include #include #include #include #include #include #include #include #include #include #include class Client : public QDialog { Q_OBJECT QThread workerThread; public: class MessageHandler { public: MessageHandler(std::function cb) : m_cb(cb) {} void operator()() { m_cb(); } private: std::function m_cb; }; Client(QWidget *parent = nullptr); Client(QWidget *parent, int count, char** arguments); ~Client(); void start(); void closeConnection(); MessageHandler createMessageHandler(std::function cb); public slots: void sendMessage(const QString& s); void sendEncoded(std::string message); signals: void messageReceived(QString s); private: void handleMessages(); int argc; char** argv; int m_client_socket_fd; };