From d51e34e66ad5fbce9f79b3d2a1b11fac01ef029e Mon Sep 17 00:00:00 2001 From: trilene Date: Thu, 23 Jul 2020 19:38:40 -0400 Subject: [PATCH] Cancel sent CallInvite if no response within expiry --- src/CallManager.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/CallManager.cpp b/src/CallManager.cpp index 37b150b..c987a58 100644 --- a/src/CallManager.cpp +++ b/src/CallManager.cpp @@ -41,6 +41,14 @@ CallManager::CallManager(QSharedPointer userSettings) nhlog::ui()->debug("Offer created with callid_ and roomid_: {} {}", callid_, roomid_.toStdString()); emit newMessage(roomid_, CallInvite{callid_, sdp, 0, timeoutms_}); emit newMessage(roomid_, CallCandidates{callid_, candidates, 0}); + + QTimer::singleShot(timeoutms_, this, [this](){ + if (session_.state() == WebRTCSession::State::OFFERSENT) { + emit newMessage(roomid_, CallHangUp{callid_, 0, CallHangUp::Reason::InviteTimeOut}); + endCall(); + emit ChatPage::instance()->showNotification("The remote side failed to pick up."); + } + }); }); connect(&session_, &WebRTCSession::answerCreated, this, @@ -112,7 +120,6 @@ CallManager::sendInvite(const QString &roomid) setTurnServers(); session_.setStunServer(settings_->useStunServer() ? STUN_SERVER : ""); - // TODO Add invite timeout generateCallID(); std::vector members(cache::getMembers(roomid.toStdString())); const RoomMember &callee = members.front().user_id == utils::localUser() ? members.back() : members.front();