refactoring

This commit is contained in:
2020-04-18 22:57:10 +02:00
parent baac6fef91
commit 65700e07d8
2 changed files with 5 additions and 11 deletions

View File

@@ -1,5 +1,7 @@
#include "ledhandler.h" #include "ledhandler.h"
#include <QNetworkDatagram>
LEDHandler::LEDHandler(QUdpSocket* sock, TS3Functions ts3Functions) LEDHandler::LEDHandler(QUdpSocket* sock, TS3Functions ts3Functions)
{ {
mSock = sock; mSock = sock;
@@ -13,7 +15,7 @@ LEDHandler::LEDHandler(QUdpSocket* sock, TS3Functions ts3Functions)
void LEDHandler::talkingStarted() void LEDHandler::talkingStarted()
{ {
printf("started\n"); printf("started\n");
sendColor(125, 125, 255, 125, 255); sendColor(0, 0, 125, 0, 255);
} }
void LEDHandler::talkingEnded() void LEDHandler::talkingEnded()
@@ -38,15 +40,10 @@ void LEDHandler::sendColor(int R, int G, int B, int W, int t)
msg.append(B); msg.append(B);
msg.append(W); msg.append(W);
for (int i = 0; i < msg.size(); i++) printf(msg.toStdString().c_str());
printf("%1", msg[i]);
printf("\n"); printf("\n");
if (mSock->isValid() && mSock->isOpen()) mSock->writeDatagram(msg, QHostAddress(cURL), cPORT);
mSock->write(msg);
else
printf("SOCKET ERROR: %1", mSock->errorString().toStdString().c_str());
} }
void LEDHandler::connected() void LEDHandler::connected()

View File

@@ -106,8 +106,6 @@ int ts3plugin_init() {
mUdpSock = new QUdpSocket(); mUdpSock = new QUdpSocket();
mLedHandler = new LEDHandler(mUdpSock, ts3Functions); mLedHandler = new LEDHandler(mUdpSock, ts3Functions);
mUdpSock->connectToHost(mLedHandler->cURL, mLedHandler->cPORT, QIODevice::WriteOnly);
return 0; /* 0 = success, 1 = failure, -2 = failure but client will not show a "failed to load" warning */ return 0; /* 0 = success, 1 = failure, -2 = failure but client will not show a "failed to load" warning */
/* -2 is a very special case and should only be used if a plugin displays a dialog (e.g. overlay) asking the user to disable /* -2 is a very special case and should only be used if a plugin displays a dialog (e.g. overlay) asking the user to disable
* the plugin again, avoiding the show another dialog by the client telling the user the plugin failed to load. * the plugin again, avoiding the show another dialog by the client telling the user the plugin failed to load.
@@ -119,7 +117,6 @@ void ts3plugin_shutdown() {
/* Your plugin cleanup code here */ /* Your plugin cleanup code here */
printf("PLUGIN: shutdown\n"); printf("PLUGIN: shutdown\n");
delete mUdpSock; delete mUdpSock;
delete mLedHandler; delete mLedHandler;