Skip to content
muhler edited this page Nov 23, 2011 · 1 revision

Include websocketpp.hpp

Create a websocketpp::client_ptr initialized to a new websocketpp::client object.

The client constructor will need:

  1. A boost::asio::io_service object to use to manage its async operations
  2. An object that implements the websocketpp::connection_handler interface to provide callback functions (See Handler API)

After construction, the client object will be in the initialization state. At this time you can set up client configuration options either via calling individual set options commands or by loading them in a batch from a configuration file.

Opening a new connection:
Per the websocket spec, a client can only have one connection in the connecting state at a time. Client method new_session() will create a new session and return a shared pointer to it. After this point new_session() will throw an exception if you attempt to call it again before the most recently created session has either successfully connected or failed to connect.

new_session()

  • call websocketpp::client::new_session(). This will return a session_ptr.