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, k32u port,
58 void Disconnect()
override;
67 bool IsConnected()
const override;
77 void SendRequest(
const GoRequest& request)
override;
103 const kIpAddress& Address()
const;
111 const k32u& Port()
const;
115 const k64u WRITE_THREAD_LOOP_SLEEP_USEC = 100000;
116 const k64u READ_THREAD_LOOP_SLEEP_USEC = 100000;
119 void ProcessRequest(
const ByteArray& msgpack)
const;
120 void ProcessResponse()
const;
122 void OnResponse(
const ByteArray& bytes)
const;
125 static kStatus kCall WriteThreadFunc(
void* context);
126 static kStatus kCall ReadThreadFunc(
void* context);
129 kIpAddress address = { };
132 Go::Object<kTcpClient> client;
133 bool isConnected =
false;
135 Go::Object<kThread> readThread;
136 Go::Object<kThread> writeThread;
140 Go::Object<kSerializer> serializer;
142 std::queue<GoRequest> sendQueue;
143 Go::Object<kSemaphore> sendQueueSema;
148 friend class ::GoCtrlChannelV1Tests;
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 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.
constexpr k32u GO_PXL_SDK_DEFAULT_CONTROL_PORT
Definition: Def.h:39
std::vector< Byte > ByteArray
Definition: Def.h:49
constexpr k16u MSGPACK_MESSAGE_TYPE
Definition: GoCtrlChannelV1.h:23
std::function< void(GoCtrlChannelErrorType type, k64u id, const std::exception &e)> GoCtrlChannelErrorHandler
Function to receive read / write thread errors.
Definition: GoCtrlChannel.h:37