feat(wish/cpp): split TLS implementation from the example server/client#19
feat(wish/cpp): split TLS implementation from the example server/client#19
Conversation
There was a problem hiding this comment.
renamed to clarify that this is an echo server implementation
|
|
||
| // Echo back | ||
| if (opcode == WISH_OPCODE_TEXT) | ||
| handler->SendText(msg); |
There was a problem hiding this comment.
changed to not prefixing received data with "Echo: "
| else if (opcode == WISH_OPCODE_BINARY) | ||
| handler->SendBinary(msg); | ||
| else if (opcode == WISH_OPCODE_TEXT_METADATA) | ||
| handler->SendTextMetadata(msg); |
There was a problem hiding this comment.
changed to echo back using the same opcode respectively
| std::string ca_file_; | ||
| std::string cert_file_; | ||
| std::string key_file_; | ||
|
|
||
| std::string host_; | ||
| int port_; | ||
|
|
||
| TlsContext tls_ctx_; | ||
| struct event_base* base_; | ||
| struct evdns_base* dns_base_; | ||
|
|
||
| WishHandler* handler_; | ||
|
|
||
| OpenCallback on_open_; | ||
| MessageCallback on_message_; |
There was a problem hiding this comment.
grouped variables for each layer
| return SendMessage(WISH_OPCODE_BINARY, msg); | ||
| } | ||
|
|
||
| int WishHandler::SendMetadata(bool is_text, const std::string& msg) { |
There was a problem hiding this comment.
changed to simply have dedicated methods for each of binary and text
| const uint8_t WISH_OPCODE_TEXT = 1; | ||
| const uint8_t WISH_OPCODE_BINARY = 2; | ||
| const uint8_t WISH_OPCODE_TEXT_METADATA = 3; | ||
| const uint8_t WISH_OPCODE_BINARY_METADATA = 4; |
There was a problem hiding this comment.
defined consts for the opcodes
| add_executable(wish-server examples/server.cc) | ||
| target_link_libraries(wish-server wish_handler) | ||
| add_executable(echo_server examples/echo_server.cc) | ||
| target_link_libraries(echo_server wish_handler) | ||
|
|
||
| add_executable(wish-client examples/client.cc) | ||
| target_link_libraries(wish-client wish_handler) |
There was a problem hiding this comment.
removing the wish- prefix for now for simplicity
There was a problem hiding this comment.
adding a very simple base for benchmarking
| const uint8_t WISH_OPCODE_TEXT_METADATA = 3; | ||
| const uint8_t WISH_OPCODE_BINARY_METADATA = 4; | ||
|
|
||
| // WishHandler implements the WiSH Procotol defined at https://datatracker.ietf.org/doc/html/draft-yoshino-wish |
There was a problem hiding this comment.
adding this so that agents see it
No description provided.