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