diff --git a/plugins/websocket-client/JanusWebsocketClientImpl.cpp b/plugins/websocket-client/JanusWebsocketClientImpl.cpp index 4f5b64d1b..cfeaef5df 100644 --- a/plugins/websocket-client/JanusWebsocketClientImpl.cpp +++ b/plugins/websocket-client/JanusWebsocketClientImpl.cpp @@ -318,11 +318,33 @@ void JanusWebsocketClientImpl::keepConnectionAlive() } }; +void JanusWebsocketClientImpl::destroy() +{ + if (connection) + { + json destroyMsg = { + { "janus" , "destroy" }, + { "session_id" , session_id }, + { "transaction" , std::to_string(rand()) }, + }; + try + { + connection->send(destroyMsg.dump()); + } + catch (websocketpp::exception const & e) + { + std::cout << e.what() << std::endl; +// return; + } + } +} + bool JanusWebsocketClientImpl::disconnect(bool wait) { try { + destroy(); // Stop keepAlive if (thread_keepAlive.joinable()){ is_running.store(false); diff --git a/plugins/websocket-client/JanusWebsocketClientImpl.h b/plugins/websocket-client/JanusWebsocketClientImpl.h index 33fce14a3..ca5fd042f 100644 --- a/plugins/websocket-client/JanusWebsocketClientImpl.h +++ b/plugins/websocket-client/JanusWebsocketClientImpl.h @@ -24,6 +24,7 @@ class JanusWebsocketClientImpl : public WebsocketClient virtual bool trickle(const std::string &mid, int index, const std::string &candidate, bool last); virtual bool disconnect(bool wait); void keepConnectionAlive(); + void destroy(); private: bool logged;