9 #include <DataBuffer.h>
18 std::vector<DataBuffer> _buffers;
19 std::unique_ptr<WSServer> ws_server;
21 bool wsIsConnected =
false;
25 void ws_onControlData(
const char* data,
unsigned int size);
26 void ws_onData(
const char* data,
unsigned int size);
27 int doSendBuffer(
const char* type,
unsigned int bufferId,
const void* data,
size_t size);
30 std::string _addressControl;
31 std::string _addressData;
32 std::wstring _projectName;
35 std::function<bool(JSONObject&, void*)> customOnControlData;
36 std::function<bool(const char*, unsigned int, void*)> customOnData;
38 void* controlCallbackArg =
nullptr;
39 void* binaryCallbackArg =
nullptr;
43 Gui(
unsigned int port, std::string address);
46 int setup(
unsigned int port = 5555, std::string address =
"gui");
55 int setup(std::string projectName,
unsigned int port = 5555, std::string address =
"gui");
58 bool isConnected(){
return wsIsConnected; };
68 unsigned int setBuffer(
char bufferType,
unsigned int size);
91 customOnControlData = callback;
92 controlCallbackArg = callbackArg;
110 void setBinaryDataCallback(std::function<
bool(
const char*,
unsigned int,
void*)> callback,
void* callbackArg=
nullptr){
111 customOnData = callback;
112 binaryCallbackArg = callbackArg;
124 template<
typename T,
typename A>
125 int sendBuffer(
unsigned int bufferId, std::vector<T,A> & buffer);
131 template <
typename T,
size_t N>
132 int sendBuffer(
unsigned int bufferId, T (&buffer)[N]);
140 template <
typename T>
141 int sendBuffer(
unsigned int bufferId, T* ptr,
size_t count);
147 template <
typename T>
148 int sendBuffer(
unsigned int bufferId, T value);
151 template<
typename T,
typename A>
154 const char* type =
typeid(T).name();
155 return doSendBuffer(type, bufferId, (
const void*)buffer.data(), (buffer.size()*
sizeof(T)));
158 template <
typename T,
size_t N>
161 const char* type =
typeid(T).name();
162 return doSendBuffer(type, bufferId, (
const void*)buffer, N*
sizeof(T));
165 template <
typename T>
167 const char* type =
typeid(T).name();
168 return doSendBuffer(type, bufferId, ptr, count *
sizeof(T));
171 template <
typename T>
174 const char* type =
typeid(T).name();
175 return doSendBuffer(type, bufferId, (
const void*)&value,
sizeof(T));
int sendBuffer(unsigned int bufferId, std::vector< T, A > &buffer)
Definition: Gui.h:152
DataBuffer & getDataBuffer(unsigned int bufferId)
Definition: Gui.cpp:162
Definition: WSServer.h:17
void setBinaryDataCallback(std::function< bool(const char *, unsigned int, void *)> callback, void *callbackArg=nullptr)
Definition: Gui.h:110
Definition: JSONValue.h:37
Definition: DataBuffer.h:11
int sendControl(JSONValue *root)
Definition: Gui.cpp:178
unsigned int setBuffer(char bufferType, unsigned int size)
Definition: Gui.cpp:155
void setControlDataCallback(std::function< bool(JSONObject &, void *)> callback, void *callbackArg=nullptr)
Definition: Gui.h:90