Skip to content

Commit

Permalink
Use cork in UpgradeAsync, silence a warning
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Dec 23, 2023
1 parent 1b89d82 commit b4d73a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions examples/UpgradeAsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,15 @@ int main() {
* such as res->writeStatus(...)->writeHeader(...)->end(...); or similar.*/

/* This call will immediately emit .open event */
upgradeData->httpRes->template upgrade<PerSocketData>({
/* We initialize PerSocketData struct here */
.something = 13
}, upgradeData->secWebSocketKey,
upgradeData->secWebSocketProtocol,
upgradeData->secWebSocketExtensions,
upgradeData->context);
upgradeData->httpRes->cork([upgradeData]() {
upgradeData->httpRes->template upgrade<PerSocketData>({
/* We initialize PerSocketData struct here */
.something = 13
}, upgradeData->secWebSocketKey,
upgradeData->secWebSocketProtocol,
upgradeData->secWebSocketExtensions,
upgradeData->context);
});
} else {
std::cout << "Async task done, but the HTTP socket was closed. Skipping upgrade to WebSocket!" << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion src/HttpRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ struct HttpRouter {
inline std::pair<std::string_view, bool> getUrlSegment(int urlSegment) {
if (urlSegment > urlSegmentTop) {
/* Signal as STOP when we have no more URL or stack space */
if (!currentUrl.length() || urlSegment > MAX_URL_SEGMENTS - 1) {
if (!currentUrl.length() || urlSegment > int(MAX_URL_SEGMENTS - 1)) {
return {{}, true};
}

Expand Down

0 comments on commit b4d73a2

Please sign in to comment.