GoPxL SDK
GoCtrlChannel.h
Go to the documentation of this file.
1 
9 #ifndef GO_PXL_SDK_GOCTRLCHANNEL_H
10 #define GO_PXL_SDK_GOCTRLCHANNEL_H
11 
12 
13 #include <kApi/Io/kNetwork.h>
14 #include <kApi/kApiDef.h>
15 
16 #include <GoPxLSdk/Def.h>
17 #include <GoPxLSdk/GoResponse.h>
18 #include <GoPxLSdk/GoRequest.h>
19 
20 namespace GoPxLSdk
21 {
22 
23 enum class GoCtrlChannelErrorType : uint8_t
24 {
25  Read, // Indicates there was an error while reading data.
26  Write // Indicates there was an error while writing data.
27 };
28 
32 using GoCtrlChannelResponseHandler = std::function<void(const std::shared_ptr<GoResponse> response)>;
33 
37 using GoCtrlChannelErrorHandler = std::function<void(GoCtrlChannelErrorType type, k64u id, const std::exception& e)>;
38 
44 {
45 public:
52  virtual ~GoCtrlChannel() = default;
53 
64  virtual void Connect(const kIpAddress& address, k32u port,
65  k64u connectionTimeout = GO_PXL_SDK_DEFAULT_TCP_TIMEOUT_MILLISECONDS) = 0;
66 
73  virtual void Disconnect() = 0;
74 
82  virtual bool IsConnected() const = 0;
83 
94  virtual void SendRequest(const GoRequest& request) = 0;
95 
103  virtual void SetResponseHandler(GoCtrlChannelResponseHandler callback) = 0;
104 
105 
114  virtual void SetErrorHandler(GoCtrlChannelErrorHandler callback) = 0;
115 
116 };
117 
118 }
119 
120 #endif
std::function< void(const std::shared_ptr< GoResponse > response)> GoCtrlChannelResponseHandler
Function to receive responses from the server asynchronously.
Definition: GoCtrlChannel.h:32
#define GoPxLSdkClass
Definition: Def.h:35
GoCtrlChannelErrorType
Definition: GoCtrlChannel.h:23
Interface for all control channel implementations.
Definition: GoCtrlChannel.h:43
constexpr k32u GO_PXL_SDK_DEFAULT_TCP_TIMEOUT_MILLISECONDS
Definition: Def.h:38
Definition: GoRequest.h:21
Declares the general SDK definitions.
Definition: Def.h:46
std::function< void(GoCtrlChannelErrorType type, k64u id, const std::exception &e)> GoCtrlChannelErrorHandler
Function to receive read / write thread errors.
Definition: GoCtrlChannel.h:37