Breakpoint hits reaching all the way to UI.
Nasty json only hackery right now, but fixable to support other protocols.
This commit is contained in:
@@ -37,6 +37,8 @@ public:
|
||||
virtual int Setup();
|
||||
virtual void Close();
|
||||
|
||||
virtual void SendEvent(json_t* event_json) {}
|
||||
|
||||
private:
|
||||
static void StartCallback(void* param);
|
||||
|
||||
|
||||
@@ -371,7 +371,12 @@ void WSClient::EventThread() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void WSClient::Write(const char* value) {
|
||||
void WSClient::SendEvent(json_t* event_json) {
|
||||
char* str = json_dumps(event_json, 0);
|
||||
Write(str);
|
||||
}
|
||||
|
||||
void WSClient::Write(char* value) {
|
||||
const uint8_t* buffers[] = {
|
||||
(uint8_t*)value,
|
||||
};
|
||||
@@ -475,7 +480,8 @@ void WSClient::OnMessage(const uint8_t* data, size_t length) {
|
||||
json_object_set_new(response, "result", result_json);
|
||||
|
||||
// Encode response to string and send back.
|
||||
const char* response_string = json_dumps(response, JSON_INDENT(2));
|
||||
// String freed by Write.
|
||||
char* response_string = json_dumps(response, JSON_INDENT(2));
|
||||
Write(response_string);
|
||||
|
||||
json_decref(request);
|
||||
|
||||
@@ -38,7 +38,9 @@ public:
|
||||
virtual int Setup();
|
||||
virtual void Close();
|
||||
|
||||
void Write(const char* value);
|
||||
virtual void SendEvent(json_t* event_json);
|
||||
|
||||
void Write(char* value);
|
||||
void Write(const uint8_t** buffers, size_t* lengths, size_t count,
|
||||
bool binary = true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user