Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/Simple-WebSocket-Server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreidheim <eidheim@gmail.com>2019-04-06 20:05:18 +0300
committereidheim <eidheim@gmail.com>2019-04-06 20:05:18 +0300
commit040a5939359fc00abab306be04df598b6cd6cb38 (patch)
treed7ae4ddbe65f1bdbe6e4bd46b48e380507d26b01 /ws_examples.cpp
parent36d1a9d3d8bf3ed98652f32bd531d5273dfc029b (diff)
Can now modify response header during handshake in SocketServer::on_handshake handler. Also corrected status_code needed for upgrade in on_upgrade.
Diffstat (limited to 'ws_examples.cpp')
-rw-r--r--ws_examples.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/ws_examples.cpp b/ws_examples.cpp
index 828fec8..b858048 100644
--- a/ws_examples.cpp
+++ b/ws_examples.cpp
@@ -50,6 +50,11 @@ int main() {
cout << "Server: Closed connection " << connection.get() << " with status code " << status << endl;
};
+ // Can modify handshake response headers here if needed
+ echo.on_handshake = [](shared_ptr<WsServer::Connection> /*connection*/, SimpleWeb::CaseInsensitiveMultimap & /*response_header*/) {
+ return SimpleWeb::StatusCode::information_switching_protocols; // Upgrade to websocket
+ };
+
// See http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/reference.html, Error Codes for error code meanings
echo.on_error = [](shared_ptr<WsServer::Connection> connection, const SimpleWeb::error_code &ec) {
cout << "Server: Error in connection " << connection.get() << ". "