diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8a9f5668..bf79fd13 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog All changes to this project will be documented in this file. +## [9.10.3] - 2020-07-24 + +(ws) port ws transfer to the new server API + ## [9.10.2] - 2020-07-24 (websocket client) reset WebSocketTransport onClose callback in the WebSocket destructor diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index 2402ec52..3feb0d54 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "9.10.2" +#define IX_WEBSOCKET_VERSION "9.10.3" diff --git a/makefile b/makefile index dfae0dc9..161999a4 100644 --- a/makefile +++ b/makefile @@ -238,7 +238,7 @@ install_cmake_for_linux: doc: mkdocs gh-deploy -change: +change: format vim ixwebsocket/IXWebSocketVersion.h docs/CHANGELOG.md .PHONY: test diff --git a/ws/ws_transfer.cpp b/ws/ws_transfer.cpp index 51f35b75..9dd1fa5f 100644 --- a/ws/ws_transfer.cpp +++ b/ws/ws_transfer.cpp @@ -19,12 +19,12 @@ namespace ix ix::WebSocketServer server(port, hostname); server.setTLSOptions(tlsOptions); - server.setOnConnectionCallback([&server](std::shared_ptr webSocket, - std::shared_ptr connectionState, - std::unique_ptr connectionInfo) { - auto remoteIp = connectionInfo->remoteIp; - webSocket->setOnMessageCallback([webSocket, connectionState, remoteIp, &server]( - const WebSocketMessagePtr& msg) { + server.setOnClientMessageCallback( + [&server](std::shared_ptr connectionState, + ConnectionInfo& connectionInfo, + WebSocket& webSocket, + const WebSocketMessagePtr& msg) { + auto remoteIp = connectionInfo.remoteIp; if (msg->type == ix::WebSocketMessageType::Open) { spdlog::info("ws_transfer: New connection"); @@ -43,7 +43,7 @@ namespace ix connectionState->getId(), msg->closeInfo.code, msg->closeInfo.reason); - auto remaining = server.getClients().erase(webSocket); + auto remaining = server.getClients().size() - 1; spdlog::info("ws_transfer: {} remaining clients", remaining); } else if (msg->type == ix::WebSocketMessageType::Error) @@ -65,7 +65,7 @@ namespace ix size_t receivers = 0; for (auto&& client : server.getClients()) { - if (client != webSocket) + if (client.get() != &webSocket) { auto readyState = client->getReadyState(); auto id = connectionState->getId(); @@ -119,7 +119,6 @@ namespace ix } } }); - }); auto res = server.listen(); if (!res.first)