43 lines
915 B
C++

#ifndef GERMANAIRLINESVA_GACONNECTOR_WEBSOCKET_H
#define GERMANAIRLINESVA_GACONNECTOR_WEBSOCKET_H
#define BUFSIZE 1024
#define MD5LEN 16
#include <IXNetSystem.h>
#include <IXWebSocketServer.h>
#include <json.hpp>
#include "types.h"
#include "util.hpp"
#include <cstring>
#include <functional>
#include <iostream>
#include <sstream>
#include <string>
#include <utility>
class Websocket
{
private:
char lastPath[513] = "";
char lastHash[2 * MD5LEN + 1] = "";
ix::WebSocket *webSocket = nullptr;
ix::WebSocketServer *server;
std::mutex wsLock;
std::function<void(std::string)> toLog;
public:
explicit Websocket(std::function<void(const std::string)> toLog);
~Websocket();
void onClientMessageCallback(
std::shared_ptr<ix::ConnectionState> &connectionState,
ix::WebSocket &ws,
const ix::WebSocketMessagePtr &msg);
void sendData(data d);
};
#endif