From 4f41f209a22fd791d14704266a23628aecde5c46 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Mon, 27 Jul 2020 18:17:13 -0700 Subject: [PATCH] (socket utility) move ix::getFreePort to ixwebsocket library --- CMakeLists.txt | 2 ++ docs/CHANGELOG.md | 4 ++++ ixsnake/ixsnake/IXSnakeConnectionState.h | 15 ++++++++++----- ixsnake/ixsnake/IXSnakeProtocol.cpp | 2 +- {test => ixwebsocket}/IXGetFreePort.cpp | 0 {test => ixwebsocket}/IXGetFreePort.h | 0 ixwebsocket/IXWebSocketVersion.h | 2 +- test/CMakeLists.txt | 1 - test/IXHttpServerTest.cpp | 2 +- test/IXTest.h | 2 +- 10 files changed, 20 insertions(+), 10 deletions(-) rename {test => ixwebsocket}/IXGetFreePort.cpp (100%) rename {test => ixwebsocket}/IXGetFreePort.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c8dc896..7bb567b6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ set( IXWEBSOCKET_SOURCES ixwebsocket/IXConnectionState.cpp ixwebsocket/IXDNSLookup.cpp ixwebsocket/IXExponentialBackoff.cpp + ixwebsocket/IXGetFreePort.cpp ixwebsocket/IXHttp.cpp ixwebsocket/IXHttpClient.cpp ixwebsocket/IXHttpServer.cpp @@ -65,6 +66,7 @@ set( IXWEBSOCKET_HEADERS ixwebsocket/IXConnectionState.h ixwebsocket/IXDNSLookup.h ixwebsocket/IXExponentialBackoff.h + ixwebsocket/IXGetFreePort.h ixwebsocket/IXHttp.h ixwebsocket/IXHttpClient.h ixwebsocket/IXHttpServer.h diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a52d2392..9c53d1cc 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. +## [10.0.1] - 2020-07-27 + +(socket utility) move ix::getFreePort to ixwebsocket library + ## [10.0.0] - 2020-07-25 (ixwebsocket server) change legacy api with 2 nested callbacks, so that the first api takes a weak_ptr as its first argument diff --git a/ixsnake/ixsnake/IXSnakeConnectionState.h b/ixsnake/ixsnake/IXSnakeConnectionState.h index c75752a7..ea0817b3 100644 --- a/ixsnake/ixsnake/IXSnakeConnectionState.h +++ b/ixsnake/ixsnake/IXSnakeConnectionState.h @@ -19,11 +19,7 @@ namespace snake public: virtual ~SnakeConnectionState() { - if (subscriptionThread.joinable()) - { - subscriptionRedisClient.stop(); - subscriptionThread.join(); - } + stopSubScriptionThread(); } std::string getNonce() @@ -61,6 +57,15 @@ namespace snake return _redisClient; } + void stopSubScriptionThread() + { + if (subscriptionThread.joinable()) + { + subscriptionRedisClient.stop(); + subscriptionThread.join(); + } + } + // We could make those accessible through methods std::thread subscriptionThread; std::string appChannel; diff --git a/ixsnake/ixsnake/IXSnakeProtocol.cpp b/ixsnake/ixsnake/IXSnakeProtocol.cpp index ef6d7d73..d291d012 100644 --- a/ixsnake/ixsnake/IXSnakeProtocol.cpp +++ b/ixsnake/ixsnake/IXSnakeProtocol.cpp @@ -261,7 +261,7 @@ namespace snake auto body = pdu["body"]; auto subscriptionId = body["subscription_id"]; - state->redisClient().stop(); + state->stopSubScriptionThread(); nlohmann::json response = {{"action", "rtm/unsubscribe/ok"}, {"id", pduId}, diff --git a/test/IXGetFreePort.cpp b/ixwebsocket/IXGetFreePort.cpp similarity index 100% rename from test/IXGetFreePort.cpp rename to ixwebsocket/IXGetFreePort.cpp diff --git a/test/IXGetFreePort.h b/ixwebsocket/IXGetFreePort.h similarity index 100% rename from test/IXGetFreePort.h rename to ixwebsocket/IXGetFreePort.h diff --git a/ixwebsocket/IXWebSocketVersion.h b/ixwebsocket/IXWebSocketVersion.h index ba54199e..ba2c25d3 100644 --- a/ixwebsocket/IXWebSocketVersion.h +++ b/ixwebsocket/IXWebSocketVersion.h @@ -6,4 +6,4 @@ #pragma once -#define IX_WEBSOCKET_VERSION "10.0.0" +#define IX_WEBSOCKET_VERSION "10.0.1" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bc223945..48657a12 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -37,7 +37,6 @@ set (SOURCES test_runner.cpp IXTest.cpp - IXGetFreePort.cpp ../third_party/msgpack11/msgpack11.cpp IXSocketTest.cpp diff --git a/test/IXHttpServerTest.cpp b/test/IXHttpServerTest.cpp index 17b4904f..39833b3d 100644 --- a/test/IXHttpServerTest.cpp +++ b/test/IXHttpServerTest.cpp @@ -4,9 +4,9 @@ * Copyright (c) 2019 Machine Zone. All rights reserved. */ -#include "IXGetFreePort.h" #include "catch.hpp" #include +#include #include #include diff --git a/test/IXTest.h b/test/IXTest.h index 4a49d38b..b7c68a27 100644 --- a/test/IXTest.h +++ b/test/IXTest.h @@ -6,9 +6,9 @@ #pragma once -#include "IXGetFreePort.h" #include #include +#include #include #include #include