MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / Disconnect

Method Disconnect

plugins/twitch/chat-connection.cpp:467–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465}
466
467void TwitchChatConnection::Disconnect()
468{
469 std::lock_guard<std::mutex> lock(_connectMtx);
470 if (_state == State::DISCONNECTED) {
471 vblog(LOG_INFO, "TwitchChatConnection already disconnected");
472 return;
473 }
474
475 _stop = true;
476
477 websocketpp::lib::error_code ec;
478 _client.close(_connection, websocketpp::close::status::normal,
479 "Twitch chat connection stopping", ec);
480 if (ec) {
481 blog(LOG_INFO, "TwitchChatConnection close failed: %s",
482 ec.message().c_str());
483
484 // TODO: avoid using stop()
485 _stop = true;
486 std::this_thread::sleep_for(3s);
487 _client.stop();
488 }
489
490 {
491 std::unique_lock<std::mutex> waitLock(_waitMtx);
492 _cv.notify_all();
493 }
494
495 if (_thread.joinable()) {
496 _thread.join();
497 }
498}
499
500static std::string toLowerCase(const std::string &str)
501{

Callers 2

DisconnectAllMethod · 0.45
HandleReconnectMethod · 0.45

Calls 2

closeMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected