Skip to content

Commit 864200b

Browse files
Review Changes requested
1 parent 52656e6 commit 864200b

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

include/crow/app.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,22 @@ namespace crow
563563
else
564564
#endif
565565
{
566-
server_->close_websockets(websockets_);
566+
close_websockets(websockets_);
567567
if (server_) { server_->stop(); }
568568
}
569569
}
570570

571+
void close_websockets(const std::vector<crow::websocket::connection*>& websockets)
572+
{
573+
std::vector<crow::websocket::connection*> websockets_to_close = websockets;
574+
for (auto websocket : websockets_to_close)
575+
{
576+
CROW_LOG_INFO << "Quitting Websocket: " << websocket;
577+
websocket->close("Websocket Closed");
578+
}
579+
}
580+
581+
571582
void add_websocket(crow::websocket::connection* conn)
572583
{
573584
websockets_.push_back(conn);

include/crow/http_server.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,7 @@ namespace crow // NOTE: Already documented in "crow/app.h"
251251
io_context_.stop(); // Close main io_service
252252
}
253253

254-
void close_websockets(const std::vector<crow::websocket::connection*>& websockets,
255-
const std::string& reason = "Server Application Terminated")
256-
{
257-
// Make a copy to avoid issues if closing modifies the original collection
258-
std::vector<crow::websocket::connection*> websockets_to_close = websockets;
259-
for (auto websocket : websockets_to_close)
260-
{
261-
CROW_LOG_INFO << "Quitting Websocket: " << websocket;
262-
websocket->close(reason);
263-
}
264-
}
265-
254+
266255
uint16_t port() const {
267256
return acceptor_.local_endpoint().port();
268257
}

0 commit comments

Comments
 (0)