libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
RpcClientInfo.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef RPCCLIENTINFO_H_
32 #define RPCCLIENTINFO_H_
33 
34 #include "../Variable.h"
35 #include <memory>
36 #include <condition_variable>
37 #include <atomic>
38 
39 namespace BaseLib
40 {
41 
42 class FileDescriptor;
43 class TcpSocket;
44 
45 namespace Security
46 {
47  class Acls;
48  typedef std::shared_ptr<Acls> PAcls;
49 }
50 
51 enum class RpcClientType
52 {
53  generic,
54  ipsymcon,
55  ccu2,
58 };
59 
60 enum class RpcType
61 {
62  unknown,
63  xml,
64  binary,
65  json,
66  websocket,
67  mqtt,
68  rest,
69  webserver
70 };
71 
73 {
74 public:
75  int32_t id = -1;
76  bool sendEventsToRpcServer = false;
77  bool closed = false;
78  bool addon = false;
79  bool flowsServer = false;
80  bool scriptEngineServer = false;
81  bool ipcServer = false;
82  bool mqttClient = false;
83  bool familyModule = false;
84  std::string webSocketClientId;
85  std::string address;
86  int32_t port = 0;
87  std::string initUrl;
88  std::string initInterfaceId;
89  std::string language;
90  std::string user;
91  bool authenticated = false;
92  bool hasClientCertificate = false;
93  std::string distinguishedName;
95 
98  bool initKeepAlive = false;
99  bool initBinaryMode = false;
100  bool initNewFormat = false;
101  bool initSubscribePeers = false;
102  bool initJsonMode = false;
103  bool initSendNewDevices = true;
104 
108  uint64_t peerId = 0;
109 
110  std::shared_ptr<FileDescriptor> socketDescriptor;
111  std::shared_ptr<TcpSocket> socket;
112 
113  std::atomic<int64_t> lastReceivedPacket;
114 
115  //{{{ Invoke variables
116  std::mutex invokeMutex;
117  std::mutex requestMutex;
118  std::condition_variable requestConditionVariable;
120  std::atomic_bool waitForResponse;
121  //}}}
122 
123  RpcClientInfo();
124  RpcClientInfo(RpcClientInfo const& rhs);
125  virtual ~RpcClientInfo() = default;
126 
127  RpcClientInfo& operator=(const RpcClientInfo& rhs);
128 
132  PVariable serialize();
133  void unserialize(BaseLib::SharedObjects* bl, PVariable data);
134 protected:
136 };
137 
138 typedef std::shared_ptr<RpcClientInfo> PRpcClientInfo;
139 
140 }
141 
142 #endif
std::shared_ptr< FileDescriptor > socketDescriptor
Definition: RpcClientInfo.h:110
This is the base library main class.
Definition: BaseLib.h:95
Definition: RpcClientInfo.h:72
std::mutex invokeMutex
Definition: RpcClientInfo.h:116
Definition: BaseLib.cpp:34
std::shared_ptr< RpcClientInfo > PRpcClientInfo
Definition: ScriptInfo.h:47
std::string initUrl
Definition: RpcClientInfo.h:87
std::atomic_bool waitForResponse
Definition: RpcClientInfo.h:120
std::shared_ptr< TcpSocket > socket
Definition: RpcClientInfo.h:111
Security::PAcls acls
Definition: RpcClientInfo.h:94
std::string language
Definition: RpcClientInfo.h:89
std::string distinguishedName
Definition: RpcClientInfo.h:93
std::string user
Definition: RpcClientInfo.h:90
std::string address
Definition: RpcClientInfo.h:85
PVariable rpcResponse
Definition: RpcClientInfo.h:119
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
std::string webSocketClientId
Definition: RpcClientInfo.h:84
std::shared_ptr< Acls > PAcls
Definition: Acls.h:357
uint64_t peerId
Definition: UiElements.h:214
RpcClientType
Definition: RpcClientInfo.h:51
std::mutex requestMutex
Definition: RpcClientInfo.h:117
RpcType
Definition: RpcClientInfo.h:60
PVariable serializedInfo
Definition: RpcClientInfo.h:135
std::condition_variable requestConditionVariable
Definition: RpcClientInfo.h:118
std::string initInterfaceId
Definition: RpcClientInfo.h:88
std::atomic< int64_t > lastReceivedPacket
Definition: RpcClientInfo.h:113