added new patrons

This commit is contained in:
Ryzerth
2020-10-04 15:23:40 +02:00
parent 60342de9c0
commit eff7bbdd5a
6 changed files with 20 additions and 186 deletions

View File

@ -56,6 +56,9 @@ private:
static void start(void* ctx) {
RTLTCPSourceModule* _this = (RTLTCPSourceModule*)ctx;
if (_this->running) {
return;
}
if (!_this->client.connectToRTL(_this->ip, _this->port)) {
spdlog::error("Could not connect to {0}:{1}", _this->ip, _this->port);
return;
@ -73,6 +76,9 @@ private:
static void stop(void* ctx) {
RTLTCPSourceModule* _this = (RTLTCPSourceModule*)ctx;
if (!_this->running) {
return;
}
_this->running = false;
_this->stream.stopWriter();
_this->workerThread.join();

View File

@ -24,6 +24,10 @@ public:
}
bool connectToRTL(char* host, uint16_t port) {
if (connected) {
return true;
}
struct addrinfo *result = NULL;
struct addrinfo *ptr = NULL;
struct addrinfo hints;
@ -62,12 +66,18 @@ public:
}
freeaddrinfo(result);
connected = true;
return true;
}
void disconnect() {
if (!connected) {
return;
}
closesocket(sock);
WSACleanup();
connected = false;
}
// struct command_t {
@ -116,5 +126,6 @@ public:
private:
SOCKET sock;
bool connected = false;
};