4 #include <websocketpp/config/asio_no_tls_client.hpp>
5 #include <websocketpp/client.hpp>
6 #include <websocketpp/common/thread.hpp>
7 #include <websocketpp/common/functional.hpp>
9 #include <condition_variable>
14 typedef websocketpp::config::asio_client::message_type::ptr
message_ptr;
32 void init(
const std::string& app_name,
const std::string& app_version,
33 std::string
server=
"", std::string local_database_name=
"");
48 Snoop&
operator()(
const std::string& type, std::string fl=
"",
int loc=-1, std::string method=
"");
83 bool authenticate(std::function<
void (std::string,
bool)>, std::string user=
"", std::string pass=
"");
98 bool add_user(std::string user, std::string password);
websocketpp::config::asio_client::message_type::ptr message_ptr
Definition: ComputeThread.hh:14
websocketpp::client< websocketpp::config::asio_client > WebsocketClient
Definition: Snoop.hh:39
websocketpp::client< websocketpp::config::asio_client > WebsocketClient
Definition: SnoopPrivate.hh:13
websocketpp::config::asio_client::message_type::ptr message_ptr
Definition: SnoopPrivate.hh:14
C++ representation of a run entry.
Definition: Snoop.hh:151
C++ representation of a log entry.
Definition: Snoop.hh:180
C++ representation of a payload entry.
Definition: Snoop.hh:209
Logging class with functionality to send log information to a remote server using a websocket connect...
Definition: Snoop.hh:54
Definition: SnoopPrivate.hh:18
void sync_payloads_with_server(bool from_wsthread=false)
As above, but only for payload data.
bool add_user(std::string user, std::string password)
Add a user/password combo to the user database.
void obtain_uuid()
Obtain a uuid by finding the last AppEntry stored in the local database.
void on_client_message(websocketpp::connection_hdl hdl, message_ptr msg)
sqlite3_stmt * insert_statement
Prepared statements (only need to prepare these once).
Definition: SnoopPrivate.hh:159
bool connection_attempt_failed
Definition: SnoopPrivate.hh:168
bool store_app_entry_without_lock(Snoop::AppEntry &)
void start_websocket_client()
Start the websocket client.
std::string get_user_uuid(const std::string &app_name)
Get a string which uniquely identifies the current user.
std::mutex connection_mutex
Definition: SnoopPrivate.hh:166
bool store_app_entry(Snoop::AppEntry &)
Store an app entry in the database.
void on_client_close(websocketpp::connection_hdl hdl)
void create_tables()
Ensure that the required tables are present in the database file.
sqlite3_stmt * id_for_uuid_statement
Definition: SnoopPrivate.hh:159
std::string last_seen_version(std::string machine_id)
Return version of last run seen on given device.
void on_client_fail(websocketpp::connection_hdl hdl)
Snoop & operator<<(const Flush &)
std::function< void(std::string, bool)> authentication_callback
Definition: SnoopPrivate.hh:183
void sync_with_server(bool from_wsthread=false)
Ensure that the local database is synchronised with the.
Snoop * snoop_
Definition: SnoopPrivate.hh:100
std::thread wsclient_thread
Definition: SnoopPrivate.hh:165
void sync_logs_with_server(bool from_wsthread=false)
As above, but only for log entries.
std::mutex call_mutex
Definition: SnoopPrivate.hh:178
void on_client_open(websocketpp::connection_hdl hdl)
WebsocketClient wsclient
Websocket client to talk to a remote logging server.
Definition: SnoopPrivate.hh:164
bool store_payload_entry(Snoop::PayLoad &)
Store payload data in the local database.
void init(const std::string &app_name, const std::string &app_version, std::string server="", std::string local_database_name="")
Initialise the logging stream.
sqlite3 * auth_db
Definition: SnoopPrivate.hh:102
Snoop::AppEntry this_app_
Definition: SnoopPrivate.hh:104
bool connection_is_open
Definition: SnoopPrivate.hh:168
bool store_log_entry(Snoop::LogEntry &, bool avoid_server_duplicates)
Store a log entry in the local database.
Snoop & payload(const std::vector< char > &)
Log payload data.
void set_local_type(const std::string &type)
bool is_connected() const
Are we connected to the log server?
bool is_ticket_valid(std::string ticket_uuid)
Get status of a given authentication ticket.
std::vector< Snoop::AppEntry > get_app_registrations(std::string uuid_filter="")
Return a vector of all aps registered in the database.
Snoop::LogEntry this_log_
Definition: SnoopPrivate.hh:105
void create_authentication_tables()
Ensure that the required authentication tables are present in the authentication database.
std::mutex sqlite_mutex
Definition: SnoopPrivate.hh:160
void sync_runs_with_server(bool from_wsthread=false)
As above, but only for run entries.
bool secure
Definition: SnoopPrivate.hh:179
bool authenticate(std::function< void(std::string, bool)>, std::string user="", std::string pass="")
Authentication logic; passes ticket or credentials to server, and registers callback function for whe...
void store_ticket(std::string ticket_uuid, int user_id, bool valid)
std::set< std::string > local_types
Definition: SnoopPrivate.hh:181
sqlite3 * payload_db
Definition: SnoopPrivate.hh:102
sqlite3_stmt * payload_insert_statement
Definition: SnoopPrivate.hh:159
std::string ticket_for_login(std::string user, std::string password)
Get status of given user/pass combo.
std::condition_variable connection_cv
Definition: SnoopPrivate.hh:167
std::string server_
Definition: SnoopPrivate.hh:106
sqlite3 * db
Definition: SnoopPrivate.hh:102
WebsocketClient::connection_ptr connection
Definition: SnoopPrivate.hh:169
websocketpp::connection_hdl our_connection_hdl
Definition: SnoopPrivate.hh:170
Snoop & operator()(const std::string &type, std::string fl="", int loc=-1, std::string method="")
Operator to initialise a logging entry with the type of.
server
Definition: cadabra2_defaults.py:156