9 #ifndef GO_PXL_SDK_GOCTRLCHANNELV1_H
10 #define GO_PXL_SDK_GOCTRLCHANNELV1_H
15 #include "GoApi/Object.h"
17 #include "kApi/Threads/kSemaphore.h"
19 class GoCtrlChannelV1Tests;
49 void Connect(
const kIpAddress& address, k16u port,
58 void Disconnect()
override;
67 bool IsConnected()
const override;
77 void SendRequest(
const GoRequest& request)
override;
113 const kIpAddress& Address()
const;
121 const k16u Port()
const;
125 const k64u WRITE_THREAD_LOOP_SLEEP_USEC = 100000;
126 const k64u READ_THREAD_LOOP_SLEEP_USEC = 100000;
129 void ProcessRequest(
const ByteArray& msgpack)
const;
130 void ProcessResponse()
const;
132 void OnResponse(
const ByteArray& bytes)
const;
133 void OnWriteError(k64u
id,
const std::exception& e)
const;
134 void OnReadError(
ReadErrorType readErrorType,
const std::exception& e)
const;
136 static kStatus kCall WriteThreadFunc(
void* context);
137 static kStatus kCall ReadThreadFunc(
void* context);
140 kIpAddress address = { };
143 Go::Object<kTcpClient> client;
144 bool isConnected =
false;
146 Go::Object<kThread> readThread;
147 Go::Object<kThread> writeThread;
151 Go::Object<kSerializer> serializer;
153 std::queue<GoRequest> sendQueue;
154 Go::Object<kSemaphore> sendQueueSema;
161 friend class ::GoCtrlChannelV1Tests;
std::function< void(const std::shared_ptr< GoResponse > response)> GoCtrlChannelResponseHandler
Function to receive responses from the server asynchronously.
Definition: GoCtrlChannel.h:34
constexpr k16u GO_PXL_SDK_DEFAULT_CONTROL_PORT
Definition: Def.h:39
#define GoPxLSdkClass
Definition: Def.h:35
Interface for all control channel implementations.
Definition: GoCtrlChannel.h:50
constexpr k16u JSON_MESSAGE_TYPE
Definition: GoCtrlChannelV1.h:24
Definition: GoCtrlChannelV1.h:26
constexpr k32u GO_PXL_SDK_DEFAULT_TCP_TIMEOUT_MILLISECONDS
Definition: Def.h:38
Definition: GoRequest.h:21
Declares the general SDK definitions.
std::vector< Byte > ByteArray
Definition: Def.h:49
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
constexpr k16u MSGPACK_MESSAGE_TYPE
Definition: GoCtrlChannelV1.h:23
std::function< void(ReadErrorType readErrorType, const std::exception &e)> GoCtrlChannelReadErrorHandler
Function to receive read thread errors.
Definition: GoCtrlChannel.h:44