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

The deepstream.io C++ client.

This class handles all public deepstream functionality through a json interface.

Single-threaded, blocking WebSockets are implemented using the POCO library. The user must regularly poll Deepstream::process_messages() to check for new messages, and run the necessary handlers.

See also POCO WebSocket Documentation

Data Fields

EventWrapper

EventWrapper deepstream::Deepstream::event

PresenceWrapper

PresenceWrapper deepstream::Deepstream::presence

Member Typedef Documentation

LoginCallback

typedef std::function<void(const json &&client_data)> deepstream::Deepstream::LoginCallback

argument type description
client_data json Client data received from the serv

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

Constructor & Destructor Documentation

Deepstream(uri)

deepstream::Deepstream::Deepstream(const std::string & uri)

argument type description
uri std::string The URI of the deepstream server to connect to, including the path. e.g. "0.0.0.0:6020/deepstream".

Instantiate the deepstream client and open a connection.

Note: The user should make a call to login() soon after instantiating the client, or the server may terminate the connection (configurable with server config option unauthenticatedClientTimeout).

Member Function Documentation

process_messages()

void deepstream::Deepstream::process_messages()

Instantiate the deepstream client and open a connection.

This function reads all incoming messages from the websocket and executes the appropriate callbacks; it blocks until there are no remaining messages to be read.

login()

void deepstream::Deepstream::login()

Try to login anonymously.

login(auth)

void deepstream::Deepstream::login (const json::object_t & auth)

argument type description
auth json::object_t User authentication data

Try to login with the given auth data.

login(callback)

void deepstream::Deepstream::login (const LoginCallback &  callback)

argument type description
callback LoginCallback A function that will be invoked with user data upon successful login.

Try to login anonymously, with a callback giving auth data on success

login(auth,callback)

void deepstream::Deepstream::login (const json::object_t & auth, const LoginCallback & callback)

argument type description
auth json::object_t User authentication data
callback LoginCallback A function that will be invoked with user data upon successful login.

Try to login with the given auth data.

Given a client in AWAIT_CONNECTION state, this function attempts to log in with the given authentication data.

The format of the user authentication data depends on the authentication method used by the server.

Login occurs asynchronously, so the client will operate in 'offline mode' until the ConnectionState is OPEN.

close()

void deepstream::Deepstream::close()

get_connection_state()

ConnectionState deepstream::Deepstream::get_connection_state()

Retrieve the current connection state of the client.