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 ReadErrorType
24 {
25  Unknown, // Indicates there was an unhandled error.
26  DeserializationError, // Indicates there was an error while deserializing data.
27  InvalidMessageType, // Indicates the received message type is invalid.
28  InvalidMessageContent, // Indicates the received message content is invalid.
29 };
30 
34 using GoCtrlChannelResponseHandler = std::function<void(const std::shared_ptr<GoResponse> response)>;
35 
39 using GoCtrlChannelWriteErrorHandler = std::function<void(k64u id, const std::exception& e)>;
40 
44 using GoCtrlChannelReadErrorHandler = std::function<void(ReadErrorType readErrorType, const std::exception& e)>;
45 
51 {
52 public:
59  virtual ~GoCtrlChannel() = default;
60 
71  virtual void Connect(const kIpAddress& address, k16u port,
72  k64u connectionTimeout = GO_PXL_SDK_DEFAULT_TCP_TIMEOUT_MILLISECONDS) = 0;
73 
80  virtual void Disconnect() = 0;
81 
89  virtual bool IsConnected() const = 0;
90 
101  virtual void SendRequest(const GoRequest& request) = 0;
102 
110  virtual void SetResponseHandler(GoCtrlChannelResponseHandler callback) = 0;
111 
112 
121  virtual void SetWriteErrorHandler(GoCtrlChannelWriteErrorHandler callback) = 0;
122 
131  virtual void SetReadErrorHandler(GoCtrlChannelReadErrorHandler callback) = 0;
132 };
133 
134 }
135 
136 #endif
std::function< void(const std::shared_ptr< GoResponse > response)> GoCtrlChannelResponseHandler
Function to receive responses from the server asynchronously.
Definition: GoCtrlChannel.h:34
#define GoPxLSdkClass
Definition: Def.h:35
Interface for all control channel implementations.
Definition: GoCtrlChannel.h:50
constexpr k32u GO_PXL_SDK_DEFAULT_TCP_TIMEOUT_MILLISECONDS
Definition: Def.h:38
Definition: GoRequest.h:21
Declares the general SDK definitions.
ReadErrorType
Definition: GoCtrlChannel.h:23
std::function< void(k64u id, const std::exception &e)> GoCtrlChannelWriteErrorHandler
Function to receive write thread errors.
Definition: GoCtrlChannel.h:39
Definition: Def.h:46
std::function< void(ReadErrorType readErrorType, const std::exception &e)> GoCtrlChannelReadErrorHandler
Function to receive read thread errors.
Definition: GoCtrlChannel.h:44