Skip to content

Commit

Permalink
Merge pull request #5 from clevertech/fix/lingering-participants
Browse files Browse the repository at this point in the history
Add janus:destroy message to client disconnect
  • Loading branch information
Chad Furman authored Oct 26, 2018
2 parents c8cdef7 + 6fc3028 commit e427d3b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions plugins/websocket-client/JanusWebsocketClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions plugins/websocket-client/JanusWebsocketClientImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e427d3b

Please sign in to comment.