Ring Daemon
Loading...
Searching...
No Matches
jami::PresenceManager Class Reference

#include <presence_manager.h>

Collaboration diagram for jami::PresenceManager:
Collaboration graph

Public Types

using DevicePresenceCallback = std::function< void(const std::string &uri, const dht::PkId &deviceId, bool online)>
 
using PresenceCallback = std::function< void(const std::string &uri, bool online)>
 

Public Member Functions

uint64_t addDeviceListener (DevicePresenceCallback cb)
 Add a listener for device presence changes.
 
uint64_t addListener (PresenceCallback cb)
 Add a listener for presence changes.
 
std::vector< dht::PkId > getDevices (const std::string &uri) const
 Get the list of devices for a tracked buddy.
 
std::map< std::string, boolgetTrackedBuddyPresence () const
 Get the presence status of all tracked buddies.
 
bool isOnline (const std::string &uri) const
 Check if a buddy is currently online.
 
 PresenceManager (const std::shared_ptr< dht::DhtRunner > &dht)
 
void refresh ()
 Refresh all tracked buddies.
 
void removeDeviceListener (uint64_t token)
 Remove a listener using the token returned by addDeviceListener.
 
void removeListener (uint64_t token)
 Remove a listener using the token returned by addListener.
 
void trackBuddy (const std::string &uri)
 Start tracking a buddy.
 
void untrackBuddy (const std::string &uri)
 Stop tracking a buddy.
 
 ~PresenceManager ()
 

Detailed Description

Definition at line 34 of file presence_manager.h.

Member Typedef Documentation

◆ DevicePresenceCallback

using jami::PresenceManager::DevicePresenceCallback = std::function<void(const std::string& uri, const dht::PkId& deviceId, bool online)>

Definition at line 38 of file presence_manager.h.

◆ PresenceCallback

using jami::PresenceManager::PresenceCallback = std::function<void(const std::string& uri, bool online)>

Definition at line 37 of file presence_manager.h.

Constructor & Destructor Documentation

◆ PresenceManager()

jami::PresenceManager::PresenceManager ( const std::shared_ptr< dht::DhtRunner > &  dht)

Definition at line 24 of file presence_manager.cpp.

◆ ~PresenceManager()

jami::PresenceManager::~PresenceManager ( )

Definition at line 28 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

Member Function Documentation

◆ addDeviceListener()

uint64_t jami::PresenceManager::addDeviceListener ( DevicePresenceCallback  cb)

Add a listener for device presence changes.

The callback will be called whenever a device of a tracked buddy goes online or offline.

Returns
A token that can be used to remove the listener.

Definition at line 129 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ addListener()

uint64_t jami::PresenceManager::addListener ( PresenceCallback  cb)

Add a listener for presence changes.

The callback will be called whenever a tracked buddy goes online or offline.

Returns
A token that can be used to remove the listener.

Definition at line 113 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getDevices()

std::vector< dht::PkId > jami::PresenceManager::getDevices ( const std::string &  uri) const

Get the list of devices for a tracked buddy.

Definition at line 100 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ getTrackedBuddyPresence()

std::map< std::string, bool > jami::PresenceManager::getTrackedBuddyPresence ( ) const

Get the presence status of all tracked buddies.

Definition at line 89 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ isOnline()

bool jami::PresenceManager::isOnline ( const std::string &  uri) const

Check if a buddy is currently online.

Definition at line 78 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ refresh()

void jami::PresenceManager::refresh ( )

Refresh all tracked buddies.

This should be called when the DHT is restarted.

Definition at line 145 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ removeDeviceListener()

void jami::PresenceManager::removeDeviceListener ( uint64_t  token)

Remove a listener using the token returned by addDeviceListener.

Definition at line 138 of file presence_manager.cpp.

◆ removeListener()

void jami::PresenceManager::removeListener ( uint64_t  token)

Remove a listener using the token returned by addListener.

Definition at line 122 of file presence_manager.cpp.

◆ trackBuddy()

void jami::PresenceManager::trackBuddy ( const std::string &  uri)

Start tracking a buddy.

Increments the reference count for the given URI. If the buddy was not tracked, it starts listening on the DHT.

Definition at line 39 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

◆ untrackBuddy()

void jami::PresenceManager::untrackBuddy ( const std::string &  uri)

Stop tracking a buddy.

Decrements the reference count. If the count reaches zero, stops listening on the DHT.

Definition at line 58 of file presence_manager.cpp.

References jami::emitSignal().

Here is the call graph for this function:

The documentation for this class was generated from the following files: