Skip to content

add App::WebSocketRule_t#1156

Merged
gittiver merged 4 commits into
CrowCpp:masterfrom
CarloDG80:WebSocketRuleType
Apr 13, 2026
Merged

add App::WebSocketRule_t#1156
gittiver merged 4 commits into
CrowCpp:masterfrom
CarloDG80:WebSocketRuleType

Conversation

@CarloDG80
Copy link
Copy Markdown
Contributor

Add App::WebSocketRule_t to clarify and simplify WebSocket creations.
Add some comments on crow::WebSocketRule<> class.

crow::SimpleApp::WebSocketRule_t& ws = CROW_WEBSOCKET_ROUTE(app, "/ws");

ws.onaccept([](const crow::request& /*conn*/, void** userData) -> bool
{
    // ...
    return true;
});
ws.onopen([](crow::websocket::connection& conn) {
    // ...
});
ws.onclose([](crow::websocket::connection& conn, const std::string& /*reason*/, uint16_t){
    // ...
});
ws.onmessage([](crow::websocket::connection& conn, const std::string& msgData, bool is_binary) {
    // ...
});

@gittiver
Copy link
Copy Markdown
Member

gittiver commented Apr 1, 2026

Sorry, I don't see which problem this change shall solve.

@CarloDG80
Copy link
Copy Markdown
Contributor Author

Technically it doesn't solve anything, but it simplifies and clarifies the object we're going to use.
Furthermore, in simple editors (like mine) the function tooltip doesn't appear on CROW_WEBSOCKET_ROUTE() macro.
My opinion, it is more clear
crow::SimpleApp::WebSocketRule_t& ws = ...
instead
crow::WebSocketRulecrow::SimpleApp& ws = ...

@gittiver
Copy link
Copy Markdown
Member

Well, it does not harm anything and if it helps you, lets go with it.

@gittiver gittiver merged commit 21f8bcf into CrowCpp:master Apr 13, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants