This class presents an API for deepstream.io's presence functionality.
Member functions may only be invoked via the singleton member Deepstream::presence.
Member Typedef Documentation
SubscribeFn
typedef std::function<void(const std::string &name, bool online)> deepstream::Deepstream::PresenceWrapper::SubscribeFn
argument | type | description |
---|---|---|
name | std::string | The name of the user |
online | bool | Whether the user logged in or out |
A function that will be invoked with user data upon successful login.
UserList
typedef std::vector<std::string> deepstream::Deepstream::PresenceWrapper::UserList
QueryFn
typedef std::function<void(const UserList&)> deepstream::Deepstream::PresenceWrapper::QueryFn
Member Function Documentation
subscribe(callback)
SubscriptionId deepstream::Deepstream::PresenceWrapper::subscribe (SubscribeFn callback)
argument | type | description |
---|---|---|
callback | SubscribeFn | A function that accepts a username and a bool (called repeatedly) |
Subscribe to presence events.
Whenever a client successfully authenticates with a username or logs out, callback will be invoked with the username of the client and a bool 'online'. 'online' indicates whether the event is a login(true) or logout(false).
If you have multiple presence subscribers and wish to unsubscribe them individually, hold a reference to the returned SubscriptionId.
unsubscribe(id)
void deepstream::Deepstream::PresenceWrapper::unsubscribe ( SubscriptionId id)
argument | type | description |
---|---|---|
id | SubscriptionId | The subscription id. |
Unsubscribe from a specific presence subscription.
unsubscribe()
void deepstream::Deepstream::PresenceWrapper::unsubscribe ()
Unsubscribe from all presence subscriptions.
get_all(callback)
void deepstream::Deepstream::PresenceWrapper::get_all (QueryFn callback)
argument | type | description |
---|---|---|
callback | QueryFn | A function that accepts a list of usernames (called once). |
Query for all currently connected clients.