Ring Daemon 16.0.0
Loading...
Searching...
No Matches
channel_handler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <dhtnet/multiplexed_socket.h>
20// #include <opendht/crypto.h>
21
22namespace jami {
23
24using DeviceId = dht::PkId;
25using ConnectCb = std::function<void(std::shared_ptr<dhtnet::ChannelSocket>, const DeviceId&)>;
27 = std::function<void(std::shared_ptr<dhtnet::ChannelSocket>, const dht::InfoHash&)>;
28
29// using ConnectCb = dhtnet::ConnectCallback;
30// using ConnectCallbackLegacy = dhtnet::ConnectCallbackLegacy;
31
37{
38public:
40
49 virtual void connect(const DeviceId& deviceId,
50 const std::string& name,
51 ConnectCb&& cb,
52 const std::string& connectionType = "",
53 bool forceNewConnection = false)
54 = 0;
55
56 virtual void connect(const dht::InfoHash& /*infoHash*/,
57 const std::string& /*name*/,
58 ConnectCallbackLegacy&& /*cb*/) {}
59
66 virtual bool onRequest(const std::shared_ptr<dht::crypto::Certificate>& peer,
67 const std::string& name)
68 = 0;
69
76 virtual void onReady(const std::shared_ptr<dht::crypto::Certificate>& peer,
77 const std::string& name,
78 std::shared_ptr<dhtnet::ChannelSocket> channel)
79 = 0;
80};
81
82} // namespace jami
A Channel handler is used to make the link between JamiAccount and ConnectionManager Its role is to m...
virtual void connect(const dht::InfoHash &, const std::string &, ConnectCallbackLegacy &&)
virtual void connect(const DeviceId &deviceId, const std::string &name, ConnectCb &&cb, const std::string &connectionType="", bool forceNewConnection=false)=0
Ask for a new channel.
virtual void onReady(const std::shared_ptr< dht::crypto::Certificate > &peer, const std::string &name, std::shared_ptr< dhtnet::ChannelSocket > channel)=0
Called when ConnectionManager has a new channel ready.
virtual bool onRequest(const std::shared_ptr< dht::crypto::Certificate > &peer, const std::string &name)=0
Determine if we accept or not the request.
std::function< void(std::shared_ptr< dhtnet::ChannelSocket >, const DeviceId &)> ConnectCb
dht::PkId DeviceId
void emitSignal(Args... args)
Definition ring_signal.h:64
std::function< void(std::shared_ptr< dhtnet::ChannelSocket >, const dht::InfoHash &)> ConnectCallbackLegacy