18#include <opendht/thread_pool.h>
25 dhtnet::ConnectionManager&
cm)
28 , connectionManager_(
cm)
41 if (connectionManager_.isConnecting(deviceId,
channelName)) {
42 JAMI_LOG(
"Already connecting to {}", deviceId);
45 connectionManager_.connectDevice(deviceId,
channelName, std::move(
cb));
52 auto acc = account_.lock();
55 return cert->issuer->getId().toString() == acc->getUsername();
61 std::shared_ptr<dhtnet::ChannelSocket> channel)
63 auto acc = account_.lock();
66 if (
auto sm = acc->syncModule())
67 sm->cacheSyncConnection(std::move(channel),
68 cert->issuer->getId().toString(),
70 dht::ThreadPool::io().run([
account = account_, channel]() {
72 acc->sendProfile(
"", acc->getUsername(), channel->deviceId().toString());
A Channel handler is used to make the link between JamiAccount and ConnectionManager Its role is to m...
void onReady(const std::shared_ptr< dht::crypto::Certificate > &peer, const std::string &name, std::shared_ptr< dhtnet::ChannelSocket > channel) override
Launch sync process.
void connect(const DeviceId &deviceId, const std::string &, ConnectCb &&cb, const std::string &connectionType="", bool forceNewConnection=false) override
Ask for a new sync channel.
SyncChannelHandler(const std::shared_ptr< JamiAccount > &acc, dhtnet::ConnectionManager &cm)
bool onRequest(const std::shared_ptr< dht::crypto::Certificate > &peer, const std::string &name) override
Determine if we accept or not the sync request.
#define JAMI_LOG(formatstr,...)
std::function< void(std::shared_ptr< dhtnet::ChannelSocket >, const DeviceId &)> ConnectCb
void emitSignal(Args... args)
static constexpr const char SYNC_SCHEME[]