JS8Call-Improved master
Loading...
Searching...
No Matches
MessageClient.h
1#ifndef MESSAGE_CLIENT_HPP__
2#define MESSAGE_CLIENT_HPP__
3
4#include "JS8_Include/pimpl_h.h"
5#include "Message.h"
6#include "Radio.h"
7
8#include <QByteArray>
9#include <QHostAddress>
10#include <QObject>
11#include <QString>
12
13//
14// MessageClient - Manage messages sent and replies received from a
15// matching server (MessageServer) at the other end of
16// the wire
17//
18//
19// Each outgoing message type is a Qt slot
20//
21class MessageClient : public QObject {
22 Q_OBJECT
23
24 public:
25 // instantiate and initiate a host lookup on the server;
26 // messages will be queued until a server host lookup is complete
27 MessageClient(QString const &server_name, quint16 server_port,
28 QObject *parent = nullptr);
29
30 // query server details
31 QHostAddress server_host() const;
32 quint16 server_port() const;
33
34 // initiate a new server host lookup or is the server name is empty
35 // the sending of messages is disabled
36 Q_SLOT void set_server_name(QString const &server_name = {});
37
38 // change the server port messages are sent to
39 Q_SLOT void set_server_port(quint16 server_port = 0u);
40
41 // this slot is used to send an arbitrary message
42 Q_SLOT void send(Message const &message);
43
44 // this signal is emitted when a message is received
45 Q_SIGNAL void message(Message const &message);
46
47 // this signal is emitted when network errors occur or if a host
48 // lookup fails
49 Q_SIGNAL void error(QString const &) const;
50
51 private:
52 class impl;
53 pimpl<impl> m_;
54};
55
56#endif
Definition MessageClient.cpp:38
Definition Message.h:16
Definition pimpl_h.h:16