18 typedef websocketpp::lib::lock_guard<websocketpp::lib::mutex>
scoped_lock;
31 using websocketpp::lib::placeholders::_1;
32 using websocketpp::lib::bind;
39 void run(
const std::string & uri) {
41 websocketpp::lib::error_code ec;
45 "Get Connection Error: "+ec.message());
51 m_hdl = con->get_handle();
58 websocketpp::lib::thread asio_thread(&
client::run, &m_client);
64 telemetry_thread.join();
70 "Connection opened, starting telemetry!");
72 scoped_lock guard(m_lock);
79 "Connection closed, stopping telemetry!");
81 scoped_lock guard(m_lock);
88 "Connection failed, stopping telemetry!");
90 scoped_lock guard(m_lock);
96 std::stringstream val;
97 websocketpp::lib::error_code ec;
103 scoped_lock guard(m_lock);
119 val <<
"count is " << count++;
131 "Send Error: "+ec.message());
141 websocketpp::lib::mutex m_lock;
146 int main(
int argc,
char* argv[]) {
149 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
void write(level, std::string const &)
Write a string message to the given channel.
websocketpp::client< websocketpp::config::asio_client > client
void set_open_handler(open_handler h)
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)
void init_asio(io_service_ptr ptr, lib::error_code &ec)
initialize asio transport with external io_service (exception free)
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)
std::size_t run()
wraps the run method of the internal io_service object
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.