57 lines
940 B
C++
57 lines
940 B
C++
#ifndef GERMANAIRLINESVA_GACONNECTOR_SOCKET_H
|
|
#define GERMANAIRLINESVA_GACONNECTOR_SOCKET_H
|
|
|
|
#define BUFSIZE 1024
|
|
#define MD5LEN 16
|
|
|
|
#include <json.hpp>
|
|
|
|
#include "types.h"
|
|
#include "util.hpp"
|
|
|
|
#include <cstring>
|
|
#include <functional>
|
|
#include <iostream>
|
|
#include <mutex>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
#ifdef IBM
|
|
#endif
|
|
#ifdef APL
|
|
#endif
|
|
#ifdef LIN
|
|
#include <arpa/inet.h>
|
|
#include <netinet/in.h>
|
|
#include <openssl/err.h>
|
|
#include <openssl/ssl.h>
|
|
#include <sys/socket.h>
|
|
#endif
|
|
|
|
class Socket
|
|
{
|
|
private:
|
|
#ifdef LIN
|
|
SSL *ssl;
|
|
int sock;
|
|
#endif
|
|
char lastPath[513] = "";
|
|
char lastHash[2 * MD5LEN + 1] = "";
|
|
std::mutex wsLock;
|
|
std::string url;
|
|
std::function<void(std::string)> toLog;
|
|
|
|
#ifdef LIN
|
|
void logSSL();
|
|
#endif
|
|
|
|
public:
|
|
explicit Socket(std::string url,
|
|
std::function<void(const std::string)> toLog);
|
|
~Socket();
|
|
void sendData(data d);
|
|
};
|
|
|
|
#endif
|