2020-06-13 12:59:58 +00:00
|
|
|
#ifndef WF_TEST_UTILS_WS_SERVER2_HPP
|
|
|
|
#define WF_TEST_UTILS_WS_SERVER2_HPP
|
|
|
|
|
|
|
|
#include <jansson.h>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace webfuse_test
|
|
|
|
{
|
|
|
|
|
|
|
|
class IIvokationHandler
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~IIvokationHandler() = default;
|
|
|
|
virtual std::string Invoke(char const * method, json_t * params) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class WsServer2
|
|
|
|
{
|
|
|
|
WsServer2(WsServer2 const &) = delete;
|
|
|
|
WsServer2 & operator=(WsServer2 const & ) = delete;
|
|
|
|
public:
|
|
|
|
WsServer2(
|
|
|
|
IIvokationHandler& handler,
|
|
|
|
std::string const & protocol,
|
2020-06-14 17:35:50 +00:00
|
|
|
int port = 0,
|
|
|
|
bool enable_tls = false);
|
2020-06-13 12:59:58 +00:00
|
|
|
virtual ~WsServer2();
|
|
|
|
bool IsConnected();
|
|
|
|
std::string const & GetUrl() const;
|
2020-06-15 14:58:04 +00:00
|
|
|
void SendMessage(char const * message);
|
|
|
|
void SendMessage(json_t * message);
|
2020-06-13 12:59:58 +00:00
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * d;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|