Merge branch 'master' into add-close-code-to-websocket-and-fixes

This commit is contained in:
Alexandre Konieczny 2019-04-24 18:49:00 +02:00
commit f9abf3908f
4 changed files with 12 additions and 2 deletions

View File

@ -135,6 +135,11 @@ namespace ix
_conditionVariable.wait(lock); _conditionVariable.wait(lock);
} }
void SocketServer::stopAcceptingConnections()
{
_stop = true;
}
void SocketServer::stop() void SocketServer::stop()
{ {
while (true) while (true)
@ -270,6 +275,8 @@ namespace ix
connectionState = _connectionStateFactory(); connectionState = _connectionStateFactory();
} }
if (_stop) return;
// Launch the handleConnection work asynchronously in its own thread. // Launch the handleConnection work asynchronously in its own thread.
_connectionsThreads.push_back(std::make_pair( _connectionsThreads.push_back(std::make_pair(
connectionState, connectionState,

View File

@ -57,6 +57,8 @@ namespace ix
void logError(const std::string& str); void logError(const std::string& str);
void logInfo(const std::string& str); void logInfo(const std::string& str);
void stopAcceptingConnections();
private: private:
// Member variables // Member variables
int _port; int _port;

View File

@ -37,6 +37,8 @@ namespace ix
void WebSocketServer::stop() void WebSocketServer::stop()
{ {
stopAcceptingConnections();
auto clients = getClients(); auto clients = getClients();
for (auto client : clients) for (auto client : clients)
{ {

View File

@ -122,7 +122,6 @@ namespace snake
void handlePublish( void handlePublish(
std::shared_ptr<SnakeConnectionState> state, std::shared_ptr<SnakeConnectionState> state,
std::shared_ptr<ix::WebSocket> ws, std::shared_ptr<ix::WebSocket> ws,
const AppConfig& appConfig,
const nlohmann::json& pdu) const nlohmann::json& pdu)
{ {
std::vector<std::string> channels; std::vector<std::string> channels;
@ -293,7 +292,7 @@ namespace snake
} }
else if (action == "rtm/publish") else if (action == "rtm/publish")
{ {
handlePublish(state, ws, appConfig, pdu); handlePublish(state, ws, pdu);
} }
else if (action == "rtm/subscribe") else if (action == "rtm/subscribe")
{ {