send and receiver startup should be complete

This commit is contained in:
2023-01-16 00:00:42 +01:00
parent 9249ac83d9
commit e1d8e9ed4c
10 changed files with 155 additions and 16 deletions

View File

@@ -11,6 +11,8 @@
#include <string>
#include <string_view>
#include <map>
#include <set>
// fwd
namespace States {
@@ -29,6 +31,22 @@ struct ToxClient {
std::string getOwnAddress(void) const;
template<typename FN>
void forEachGroup(FN&& fn) const {
for (const auto& it : _groups) {
fn(it.first);
}
}
template<typename FN>
void forEachGroupPeer(uint32_t group_number, FN&& fn) const {
if (_groups.count(group_number)) {
for (const uint32_t peer_number : _groups.at(group_number)) {
fn(peer_number);
}
}
}
public: // tox callbacks
void onToxSelfConnectionStatus(TOX_CONNECTION connection_status);
void onToxFriendRequest(const uint8_t* public_key, std::string_view message);
@@ -60,5 +78,8 @@ struct ToxClient {
bool _tox_profile_dirty {false}; // set in callbacks
std::unique_ptr<StateI> _state;
// key groupid, value set of peer ids
std::map<uint32_t, std::set<uint32_t>> _groups;
};