2016-07-10 01:18:13 +01:00
|
|
|
#ifndef BOT_CLIENTCONNECTION
|
|
|
|
#define BOT_CLIENTCONNECTION
|
2016-07-05 00:51:53 +01:00
|
|
|
|
|
|
|
#include <websocketpp/client.hpp>
|
2016-07-10 01:18:13 +01:00
|
|
|
#include <websocketpp/config/asio_client.hpp>
|
|
|
|
#include "json/json.hpp"
|
2016-07-05 00:51:53 +01:00
|
|
|
|
|
|
|
typedef websocketpp::client<websocketpp::config::asio_tls_client> client;
|
|
|
|
|
|
|
|
using websocketpp::lib::bind;
|
|
|
|
|
|
|
|
// pull out the type of messages sent by our config
|
|
|
|
typedef websocketpp::config::asio_tls_client::message_type::ptr message_ptr;
|
|
|
|
typedef websocketpp::lib::shared_ptr<boost::asio::ssl::context> context_ptr;
|
|
|
|
typedef client::connection_ptr connection_ptr;
|
|
|
|
|
2016-07-12 23:43:23 +01:00
|
|
|
#include "GatewayHandler.hpp"
|
2016-07-10 01:18:13 +01:00
|
|
|
|
2016-07-05 00:51:53 +01:00
|
|
|
class ClientConnection {
|
|
|
|
public:
|
2016-07-10 01:18:13 +01:00
|
|
|
ClientConnection();
|
2016-07-05 00:51:53 +01:00
|
|
|
|
2016-07-10 01:18:13 +01:00
|
|
|
// Open a connection to the URI provided
|
|
|
|
void start(std::string uri);
|
2016-07-05 00:51:53 +01:00
|
|
|
|
2016-07-10 01:18:13 +01:00
|
|
|
// Event handlers
|
|
|
|
void on_socket_init(websocketpp::connection_hdl);
|
|
|
|
context_ptr on_tls_init(websocketpp::connection_hdl);
|
|
|
|
void on_fail(websocketpp::connection_hdl hdl);
|
|
|
|
void on_open(websocketpp::connection_hdl hdl);
|
2016-07-12 21:11:28 +01:00
|
|
|
void on_message(websocketpp::connection_hdl hdl, message_ptr message);
|
2016-07-10 01:18:13 +01:00
|
|
|
void on_close(websocketpp::connection_hdl);
|
2016-07-05 00:51:53 +01:00
|
|
|
|
|
|
|
private:
|
2016-07-10 01:18:13 +01:00
|
|
|
client c;
|
2016-07-12 23:43:23 +01:00
|
|
|
std::unique_ptr<GatewayHandler> gh;
|
2016-07-10 01:18:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|