47 lines
827 B
C++
47 lines
827 B
C++
#include "include/socket.h"
|
|
|
|
Socket::Socket(std::string url, std::function<void(const std::string)> toLog)
|
|
: url(url), toLog(std::move(toLog))
|
|
{
|
|
#ifdef IBM
|
|
// WSA INIT
|
|
int a = 0;
|
|
#endif
|
|
// PLATFORM AGNOSTIC
|
|
}
|
|
|
|
Socket::~Socket()
|
|
{
|
|
// PLATFORM AGNOSTIC
|
|
#ifdef IBM
|
|
// WSA DEINIT
|
|
int a = 0;
|
|
#endif
|
|
}
|
|
|
|
void Socket::sendData(data d)
|
|
{
|
|
if (strcmp(d.path, lastPath) != 0) {
|
|
strcpy(lastPath, d.path);
|
|
if (util::generateMD5(d.path, lastHash, toLog)) {
|
|
strcpy(lastHash, "NOT SET");
|
|
}
|
|
}
|
|
|
|
nlohmann::json json = {
|
|
{"altitude", d.alt},
|
|
{"vs", d.vs},
|
|
{"ias", d.ias},
|
|
{"magHdg", d.magHeading},
|
|
{"truHdg", d.truHdg},
|
|
{"totFuel", d.totFuelKg},
|
|
{"fuelFlow", d.ff},
|
|
{"hash", lastHash},
|
|
};
|
|
|
|
{
|
|
std::lock_guard<std::mutex> lock(wsLock);
|
|
// SEND
|
|
}
|
|
}
|