29 typedef websocketpp::lib::lock_guard<websocketpp::lib::mutex>
scoped_lock;
42 using websocketpp::lib::placeholders::_1;
43 using websocketpp::lib::bind;
50 void run(
const std::string & uri) {
52 websocketpp::lib::error_code ec;
56 "Get Connection Error: "+ec.message());
62 m_hdl = con->get_handle();
69 websocketpp::lib::thread asio_thread(&client::run, &m_client);
75 telemetry_thread.join();
81 "Connection opened, starting telemetry!");
83 scoped_lock guard(m_lock);
90 "Connection closed, stopping telemetry!");
92 scoped_lock guard(m_lock);
99 "Connection failed, stopping telemetry!");
101 scoped_lock guard(m_lock);
107 std::stringstream val;
108 websocketpp::lib::error_code ec;
114 scoped_lock guard(m_lock);
130 val <<
"count is " << count++;
142 "Send Error: "+ec.message());
152 websocketpp::lib::mutex m_lock;
157 int main(
int argc,
char* argv[]) {
160 std::string uri =
"ws://localhost:9002";
static level const all
Special aggregate value representing "all levels".
connection_type::ptr connection_ptr
Type of a shared pointer to the connections this server will create.
websocketpp::lib::lock_guard< websocketpp::lib::mutex > scoped_lock
websocketpp::client< websocketpp::config::asio_client > client
void set_open_handler(open_handler h)
void wait_a_bit()
Define a semi-cross platform helper method that waits/sleeps for a bit.
static level const app
Special channel for application specific logs. Not used by the library.
lib::weak_ptr< void > connection_hdl
A handle to uniquely identify a connection.
alog_type & get_alog()
Get reference to access logger.
void on_open(websocketpp::connection_hdl)
void set_close_handler(close_handler h)
The telemetry client connects to a WebSocket server and sends a message every second containing an in...
connection_ptr connect(connection_ptr con)
Begin the connection process for the given connection.
void on_fail(websocketpp::connection_hdl)
static level const disconnect
One line for each closed connection. Includes closing codes and reasons.
int main(int argc, char *argv[])
void set_access_channels(log::level channels)
Set Access logging channel.
void run(const std::string &uri)
void set_fail_handler(fail_handler h)
void clear_access_channels(log::level channels)
Clear Access logging channels.
void on_close(websocketpp::connection_hdl)
void send(connection_hdl hdl, std::string const &payload, frame::opcode::value op, lib::error_code &ec)
Create a message and add it to the outgoing send queue (exception free)
connection_ptr get_connection(uri_ptr location, lib::error_code &ec)
Get a new connection.
static level const connect
Information about new connections.