refactoring
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include "ledhandler.h"
|
||||
|
||||
#include <QNetworkDatagram>
|
||||
|
||||
LEDHandler::LEDHandler(QUdpSocket* sock, TS3Functions ts3Functions)
|
||||
{
|
||||
mSock = sock;
|
||||
@@ -13,7 +15,7 @@ LEDHandler::LEDHandler(QUdpSocket* sock, TS3Functions ts3Functions)
|
||||
void LEDHandler::talkingStarted()
|
||||
{
|
||||
printf("started\n");
|
||||
sendColor(125, 125, 255, 125, 255);
|
||||
sendColor(0, 0, 125, 0, 255);
|
||||
}
|
||||
|
||||
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(W);
|
||||
|
||||
for (int i = 0; i < msg.size(); i++)
|
||||
printf("%1", msg[i]);
|
||||
printf(msg.toStdString().c_str());
|
||||
printf("\n");
|
||||
|
||||
if (mSock->isValid() && mSock->isOpen())
|
||||
mSock->write(msg);
|
||||
else
|
||||
printf("SOCKET ERROR: %1", mSock->errorString().toStdString().c_str());
|
||||
|
||||
mSock->writeDatagram(msg, QHostAddress(cURL), cPORT);
|
||||
}
|
||||
|
||||
void LEDHandler::connected()
|
||||
|
||||
@@ -106,8 +106,6 @@ int ts3plugin_init() {
|
||||
mUdpSock = new QUdpSocket();
|
||||
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 */
|
||||
/* -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.
|
||||
@@ -119,7 +117,6 @@ void ts3plugin_shutdown() {
|
||||
/* Your plugin cleanup code here */
|
||||
printf("PLUGIN: shutdown\n");
|
||||
|
||||
|
||||
delete mUdpSock;
|
||||
delete mLedHandler;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user