2020-02-22 15:46:21 +00:00
|
|
|
#ifndef WF_TEST_UTILS_WS_SERVER_HPP
|
|
|
|
#define WF_TEST_UTILS_WS_SERVER_HPP
|
|
|
|
|
|
|
|
#include <libwebsockets.h>
|
|
|
|
#include <jansson.h>
|
|
|
|
|
|
|
|
namespace webfuse_test
|
|
|
|
{
|
|
|
|
|
|
|
|
class WebsocketServer
|
|
|
|
{
|
|
|
|
WebsocketServer(WebsocketServer const &) = delete;
|
|
|
|
WebsocketServer & operator=(WebsocketServer const &) = delete;
|
|
|
|
public:
|
|
|
|
explicit WebsocketServer(int port);
|
2020-02-23 20:02:01 +00:00
|
|
|
WebsocketServer(int port, struct lws_protocols * additionalProtocols, std::size_t additionalProtocolsCount);
|
2020-02-22 15:46:21 +00:00
|
|
|
~WebsocketServer();
|
2020-02-23 20:02:01 +00:00
|
|
|
struct lws_context * getContext();
|
2020-02-22 15:46:21 +00:00
|
|
|
void waitForConnection();
|
|
|
|
void sendMessage(json_t * message);
|
|
|
|
json_t * receiveMessage();
|
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
Private * d;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|