Skip to content

Commit

Permalink
feat: add support for WebSocket RBProtocol backend
Browse files Browse the repository at this point in the history
  • Loading branch information
Tasssadar committed Oct 31, 2023
1 parent 98fee63 commit 3fa6de1
Show file tree
Hide file tree
Showing 15 changed files with 1,349 additions and 659 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ cmake_minimum_required(VERSION 3.0)

set(SRCS
"src/rbjson.cpp"
"src/rbprotocol.cpp"
"src/rbprotocoludp.cpp"
"src/rbprotocolws.cpp"
"src/rbtcp.cpp"
"src/rbudp.cpp"
"src/rbwifi_netif.cpp"
"src/rbwifi_tcpip.cpp"
"src/mpaland-printf/printf.c"
"src/rbwebserver.c"
"src/rbwebsockets.c"
)

idf_component_register(
Expand Down
10 changes: 0 additions & 10 deletions library.properties

This file was deleted.

17 changes: 15 additions & 2 deletions src/rbjson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,32 @@ static int count_tok_size(jsmntok_t* tok) {
return itr - tok;
}


static inline void write_string_escaped(const char* str, std::ostream& ss) {
const char* start = str;
const char* end = NULL;
ss.put('"');
while (true) {
end = strchr(start, '"');
end = strpbrk(start, "\"\\\b\f\n\r\t");
if (end == NULL) {
ss.write(start, strlen(start));
ss.put('"');
return;
} else {
ss.write(start, end - start);
ss.write("\\\"", 2);
ss.put('\\');
switch(*end) {
case '"':
case '\\':
ss.put(*end);
break;
case '\b': ss.put('b'); break;
case '\f': ss.put('f'); break;
case '\n': ss.put('n'); break;
case '\r': ss.put('r'); break;
case '\t': ss.put('t'); break;
default: ss.put('?'); break;
}
start = end + 1;
}
}
Expand Down
Loading

0 comments on commit 3fa6de1

Please sign in to comment.