Ditto 4.6.0
Loading...
Searching...
No Matches
Presence.hpp
1#ifndef _DITTO_PRESENCE_MANAGER_
2#define _DITTO_PRESENCE_MANAGER_
3
4#include "DittoHandleWrapper.hpp"
5#include "PresenceGraph.hpp"
6
7#include <memory>
8#include <string>
9
10namespace ditto {
11class DittoHandleWrapper;
12
17typedef std::function<void(PresenceGraph)> PresenceCallback;
18
19typedef std::weak_ptr<PresenceCallback> PresenceObserverInternal;
20typedef std::shared_ptr<PresenceCallback> PresenceObserver;
21
25class Presence {
26 friend class Ditto;
27
28public:
35 PresenceObserver observe(PresenceCallback presence_cb);
42
43private:
44 Presence(std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper);
50 static void on_event(void *ctx, const char *graph);
51
57 void on_presence(PresenceGraph presence_graph);
58
59 std::shared_ptr<DittoHandleWrapper> ditto_handle_wrapper;
60 std::vector<PresenceObserverInternal> observers;
61 bool registered;
62};
63} // namespace ditto
64#endif
The entrypoint to the Ditto SDK.
Definition Ditto.hpp:32
Represents local peer and local peers.
Definition PresenceGraph.hpp:63
Definition Presence.hpp:25
PresenceGraph exec()
Return an immediate representation of known peers.
Definition Presence.cpp:63
PresenceObserver observe(PresenceCallback presence_cb)
This will run the provided callback when peers are updated.
Definition Presence.cpp:41
Definition Arc.hpp:10