43 lines
913 B
C++
43 lines
913 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.h"
|
|
|
|
#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
|