hyperion.ng
ProtoClientConnection.h
1 #pragma once
2 
3 // util
4 #include <utils/Logger.h>
5 #include <utils/Image.h>
6 #include <utils/ColorRgb.h>
7 #include <utils/Components.h>
8 
9 // protobuffer PROTO
10 #include "message.pb.h"
11 
12 class QTcpSocket;
13 class QTimer;
14 class Hyperion;
15 
16 namespace proto {
17 class HyperionRequest;
18 }
19 
23 class ProtoClientConnection : public QObject
24 {
25  Q_OBJECT
26 
27 public:
34  explicit ProtoClientConnection(QTcpSocket* socket, const int &timeout, QObject *parent);
35 
36 signals:
40  void clientDisconnected();
41 
42 public slots:
46  void forceClose();
47 
48 private slots:
52  void readyRead();
53 
57  void disconnected();
58 
59 private:
65  void handleMessage(const proto::HyperionRequest &message);
66 
72  void handleColorCommand(const proto::ColorRequest & message);
73 
79  void handleImageCommand(const proto::ImageRequest & message);
80 
86  void handleClearCommand(const proto::ClearRequest & message);
87 
91  void handleClearallCommand();
92 
96  void handleNotImplemented();
97 
103  void sendMessage(const google::protobuf::Message &message);
104 
108  void sendSuccessReply();
109 
115  void sendErrorReply(const std::string & error);
116 
117 private:
118  Logger*_log;
119 
121  QTcpSocket* _socket;
122 
124  const QString _clientAddress;
125 
126  QTimer*_timeoutTimer;
127  int _timeout;
128  int _priority;
129 
131  Hyperion* _hyperion;
132 
134  QByteArray _receiveBuffer;
135 };
Definition: Logger.h:32
The main class of Hyperion.
Definition: Hyperion.h:57
Definition: ProtoClientConnection.h:16
The Connection object created by a ProtoServer when a new connection is established.
Definition: ProtoClientConnection.h:23