From baac6fef91efb9d69d53becc7b607ef2f80ef3f9 Mon Sep 17 00:00:00 2001 From: rogo Date: Sat, 18 Apr 2020 20:18:45 +0200 Subject: [PATCH] added poke event --- src/ledhandler.cpp | 30 ++++++++++++++++++++++-------- src/ledhandler.h | 1 + src/plugin.cpp | 19 ++----------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/ledhandler.cpp b/src/ledhandler.cpp index 3a4ace4..17ea3b2 100644 --- a/src/ledhandler.cpp +++ b/src/ledhandler.cpp @@ -13,7 +13,7 @@ LEDHandler::LEDHandler(QUdpSocket* sock, TS3Functions ts3Functions) void LEDHandler::talkingStarted() { printf("started\n"); - sendColor(0, 0, 255, 255, 255); + sendColor(125, 125, 255, 125, 255); } void LEDHandler::talkingEnded() @@ -22,17 +22,31 @@ void LEDHandler::talkingEnded() sendColor(0, 0, 0, 0, 0); } +void LEDHandler::poked() +{ + // start timer + sendColor(0, 0, 0, 255, 5); +} + void LEDHandler::sendColor(int R, int G, int B, int W, int t) { QByteArray msg; - msg[0] = 3; // protocol: DRGBW - msg[1] = t; // timeout - msg[2] = R; // R - msg[2] = B; // G - msg[2] = G; // B - msg[2] = W; // W + msg.append(2); + msg.append(t); + msg.append(R); + msg.append(G); + msg.append(B); + msg.append(W); + + for (int i = 0; i < msg.size(); i++) + printf("%1", msg[i]); + printf("\n"); + + if (mSock->isValid() && mSock->isOpen()) + mSock->write(msg); + else + printf("SOCKET ERROR: %1", mSock->errorString().toStdString().c_str()); - mSock->write(msg); } void LEDHandler::connected() diff --git a/src/ledhandler.h b/src/ledhandler.h index 5b36241..439755e 100644 --- a/src/ledhandler.h +++ b/src/ledhandler.h @@ -15,6 +15,7 @@ public: void talkingEnded(); void talkingStarted(); + void poked(); public slots: void connected(); diff --git a/src/plugin.cpp b/src/plugin.cpp index 9af4455..eb249c4 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -56,7 +56,7 @@ const char* ts3plugin_name() { /* Plugin version */ const char* ts3plugin_version() { - return "0.4"; + return "0.4b"; } /* Plugin API version. Must be the same as the clients API major version, else the plugin fails to load. */ @@ -881,8 +881,6 @@ void ts3plugin_onClientBanFromServerEvent(uint64 serverConnectionHandlerID, anyI } int ts3plugin_onClientPokeEvent(uint64 serverConnectionHandlerID, anyID fromClientID, const char* pokerName, const char* pokerUniqueIdentity, const char* message, int ffIgnored) { - anyID myID; - printf("PLUGIN onClientPokeEvent: %llu %d %s %s %d\n", (long long unsigned int)serverConnectionHandlerID, fromClientID, pokerName, message, ffIgnored); /* Check if the Friend/Foe manager has already blocked this poke */ @@ -890,20 +888,7 @@ int ts3plugin_onClientPokeEvent(uint64 serverConnectionHandlerID, anyID fromClie return 0; /* Client will block anyways, doesn't matter what we return */ } -// if (curl) { -// curl_easy_setopt(curl, CURLOPT_URL, LED_URL_POKE); -// res = curl_easy_perform(curl); -// Sleep(500); -// res = curl_easy_perform(curl); -// Sleep(500); -// res = curl_easy_perform(curl); -// Sleep(500); -// res = curl_easy_perform(curl); -// Sleep(500); - -// curl_easy_setopt(curl, CURLOPT_URL, LED_URL_OFF); -// res = curl_easy_perform(curl); -// } + mLedHandler->poked(); return 0; /* 0 = handle normally, 1 = client will ignore the poke */ }