10 #ifndef GO_PXL_SDK_GOCTRLCHANNELV1_H
11 #define GO_PXL_SDK_GOCTRLCHANNELV1_H
16 #include "GoApi/Object.h"
18 #include "kApi/Threads/kSemaphore.h"
20 class GoCtrlChannelV1Tests;
50 void Connect(
const kIpAddress& address, k16u port,
59 void Disconnect()
override;
68 bool IsConnected()
const override;
78 void SendRequest(
const GoRequest& request)
override;
114 const kIpAddress& Address()
const;
122 const k16u Port()
const;
126 const k64u WRITE_THREAD_LOOP_SLEEP_USEC = 100000;
127 const k64u READ_THREAD_LOOP_SLEEP_USEC = 100000;
130 void ProcessRequest(
const ByteArray& msgpack)
const;
131 void ProcessResponse()
const;
133 void OnResponse(
const ByteArray& bytes)
const;
134 void OnWriteError(k64u
id,
const std::exception& e)
const;
135 void OnReadError(
ReadErrorType readErrorType,
const std::exception& e)
const;
137 static kStatus kCall WriteThreadFunc(
void* context);
138 static kStatus kCall ReadThreadFunc(
void* context);
141 kIpAddress address = { };
144 Go::Object<kTcpClient> client;
145 bool isConnected =
false;
147 Go::Object<kThread> readThread;
148 Go::Object<kThread> writeThread;
152 Go::Object<kSerializer> serializer;
154 std::queue<GoRequest> sendQueue;
155 Go::Object<kSemaphore> sendQueueSema;
162 friend class ::GoCtrlChannelV1Tests;
std::function< void(const std::shared_ptr< GoResponse > response)> GoCtrlChannelResponseHandler
Function to receive responses from the server asynchronously.
Definition: GoCtrlChannel.h:35
constexpr k16u GO_PXL_SDK_DEFAULT_CONTROL_PORT
Definition: Def.h:39
#define GoPxLSdkClass
Definition: Def.h:35
Declares the GoPxLSdk.GoCtrlChannel class.
Interface for all control channel implementations.
Definition: GoCtrlChannel.h:51
constexpr k16u JSON_MESSAGE_TYPE
Definition: GoCtrlChannelV1.h:25
Definition: GoCtrlChannelV1.h:27
constexpr k32u GO_PXL_SDK_DEFAULT_TCP_TIMEOUT_MILLISECONDS
Definition: Def.h:38
Definition: GoRequest.h:22
Declares the general SDK definitions.
std::vector< Byte > ByteArray
Definition: Def.h:49
ReadErrorType
Definition: GoCtrlChannel.h:24
std::function< void(k64u id, const std::exception &e)> GoCtrlChannelWriteErrorHandler
Function to receive write thread errors.
Definition: GoCtrlChannel.h:40
constexpr k16u MSGPACK_MESSAGE_TYPE
Definition: GoCtrlChannelV1.h:24
std::function< void(ReadErrorType readErrorType, const std::exception &e)> GoCtrlChannelReadErrorHandler
Function to receive read thread errors.
Definition: GoCtrlChannel.h:45