From fec77c4f8943e3345345a0cc0cbf8f8596bfccfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Tue, 15 Apr 2025 11:51:48 -0400 Subject: [PATCH] jamiaccount: open sip connection when needed only Change-Id: I9cfebadb157e24e029004ec04e6a170e4e3c0923 --- src/jamidht/jamiaccount.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/jamidht/jamiaccount.cpp b/src/jamidht/jamiaccount.cpp index 64cca1956f..56727a6703 100644 --- a/src/jamidht/jamiaccount.cpp +++ b/src/jamidht/jamiaccount.cpp @@ -2013,10 +2013,14 @@ JamiAccount::doRegister_() std::unique_lock lk(shared->connManagerMtx_); shared->initConnectionManager(); lk.unlock(); - shared->requestSIPConnection( - shared->getUsername(), - crt->getLongId(), - "sync"); // For git notifications, will use the same socket as sync + shared->requestMessageConnection(shared->getUsername(), crt->getLongId(), "sync"); + if (!shared->syncModule()->isConnected(crt->getLongId())) { + shared->channelHandlers_[Uri::Scheme::SYNC] + ->connect(crt->getLongId(), + "", + [](std::shared_ptr<dhtnet::ChannelSocket> socket, + const DeviceId& deviceId) {}); + } }); } }, @@ -2338,8 +2342,7 @@ JamiAccount::convModule(bool noCreation) cb(nullptr); return; } - - shared->requestSIPConnection(uri, deviceId, ""); + shared->requestMessageConnection(uri, deviceId, ""); } cb(socket); }); @@ -3253,10 +3256,10 @@ JamiAccount::sendMessage(const std::string& to, } // Else, ask for a channel to send the message - requestSIPConnection(to, deviceId, payload_type); + requestMessageConnection(to, deviceId, payload_type); }); } else { - requestSIPConnection(to, device, payload_type); + requestMessageConnection(to, device, payload_type); } } @@ -3758,7 +3761,6 @@ JamiAccount::requestSIPConnection(const std::string& peerId, bool forceNewConnection, const std::shared_ptr<SIPCall>& pc) { - requestMessageConnection(peerId, deviceId, connectionType); if (peerId == getUsername()) { if (!syncModule()->isConnected(deviceId)) channelHandlers_[Uri::Scheme::SYNC] -- GitLab