why deepstreamHub? compare us getting started faq
use cases
products
developers
company
blog contact

This class presents an API for deepstream.io's event functionality.

Member functions may only be invoked via the singleton member Deepstream::event.

Member Typedef Documentation

SubscribeFn

typedef std::function<void(const json &data)> deepstream::Deepstream::EventWrapper::SubscribeFn

A function that will be invoked with user data upon successful login.

ListenFn

typedef std::function<bool(const std::string &event_name, bool is_subscribed)> deepstream::Deepstream::EventWrapper::ListenFn

A function that will be invoked whenever a match for a provided pattern is found

Member Function Documentation

emit(eventName,data)

void deepstream::Deepstream::EventWrapper::emit (const std::string & name, json data)

argument type description
name std::string The name of the event to emit.
data json The payload to be sent.

Emit/(Publish) an event to all local and remote subscribers.

subscribe(eventName,callback)

SubscriptionId deepstream::Deepstream::EventWrapper::subscribe (const std::string & name, SubscribeFn callback)

argument type description
name std::string The name of the event to subscribe to.
callback SubscribeFn A function that will be invoked with a json payload whenever the an there is a local call to emit or an event is received from the server.

Subscribe to an event.

A function can be subscribed to many events (or the same event, multiple times) by repeated calls to this function. Likewise, many functions may be subscribed to a single event name.

If you have multiple subscribers to an event name and wish to unsubscribe them individually, hold a reference to the returned SubscriptionId.

unsubscribe(eventName,id)

void deepstream::Deepstream::EventWrapper::unsubscribe (const std::string & name, SubscriptionId subscription_id)

argument type description
name std::string The name of the event to unsubscribe from.
callback SubscriptionId The identifier from a call to event.subscribe.

Unsubscribe from an event with subscription id.

unsubscribe(eventName)

void deepstream::Deepstream::EventWrapper::unsubscribe (const std::string & name)

argument type description
name std::string The name of the event to unsubscribe from.

Unsubscribe from an event.

If more than one function is subscribed to the given event, they will all be unsubscribed.

listen(pattern,callback)

void deepstream::Deepstream::EventWrapper::listen (const std::string & pattern, const ListenFn callback)

argument type description
pattern std::string The pattern to match
callback ListenFn A function that will be called whenever an event has been initially subscribed to or is no longer subscribed.

Register the client as a listener for event subscriptions made by other clients.

Any subscriptions to event names matching the given pattern will trigger a listen callback.

unlisten(pattern)

void deepstream::Deepstream::EventWrapper::unlisten (const std::string & pattern)

argument type description
pattern std::string The pattern to unregister

Unregister a listener The pattern must equal that which was used in the call to listen(const std::string, const ListenFn)