GoPxL SDK

- Home
- Files
- Namespace

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
43 class GoPxLSdkClass GoCtrlChannel
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
GoPxLSdk::GoCtrlChannelResponseHandler
std::function< void(const std::shared_ptr< GoResponse > response)> GoCtrlChannelResponseHandler
Function to receive responses from the server asynchronously.
Definition: GoCtrlChannel.h:32
GoPxLSdkClass
#define GoPxLSdkClass
Definition: Def.h:35
GoPxLSdk::GoCtrlChannelErrorType
GoCtrlChannelErrorType
Definition: GoCtrlChannel.h:23
GoPxLSdk::GoCtrlChannelErrorType::Read
GoPxLSdk::GoCtrlChannel
Interface for all control channel implementations.
Definition: GoCtrlChannel.h:43
GoResponse.h
GO_PXL_SDK_DEFAULT_TCP_TIMEOUT_MILLISECONDS
constexpr k32u GO_PXL_SDK_DEFAULT_TCP_TIMEOUT_MILLISECONDS
Definition: Def.h:38
GoPxLSdk::GoRequest
Definition: GoRequest.h:21
Def.h
Declares the general SDK definitions.
GoRequest.h
GoPxLSdk
Definition: Def.h:46
GoPxLSdk::GoCtrlChannelErrorHandler
std::function< void(GoCtrlChannelErrorType type, k64u id, const std::exception &e)> GoCtrlChannelErrorHandler
Function to receive read / write thread errors.
Definition: GoCtrlChannel.h:37
GoPxLSdk::GoCtrlChannelErrorType::Write