reuse of http handler

This commit is contained in:
2020-04-18 15:03:43 +02:00
parent 558317311c
commit 0474bd1bce

View File

@@ -143,6 +143,7 @@ int ts3plugin_init() {
printf("PLUGIN: App path: %s\nResources path: %s\nConfig path: %s\nPlugin path: %s\n", appPath, resourcesPath, configPath, pluginPath); printf("PLUGIN: App path: %s\nResources path: %s\nConfig path: %s\nPlugin path: %s\n", appPath, resourcesPath, configPath, pluginPath);
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
curl = curl_easy_init();
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
@@ -155,6 +156,7 @@ void ts3plugin_shutdown() {
/* Your plugin cleanup code here */ /* Your plugin cleanup code here */
printf("PLUGIN: shutdown\n"); printf("PLUGIN: shutdown\n");
curl_easy_cleanup(curl);
curl_global_cleanup(); curl_global_cleanup();
/* /*
@@ -853,7 +855,7 @@ void ts3plugin_onTalkStatusChangeEvent(uint64 serverConnectionHandlerID, int sta
char name[512]; char name[512];
if(ts3Functions.getClientDisplayName(serverConnectionHandlerID, clientID, name, 512) == ERROR_ok) { if(ts3Functions.getClientDisplayName(serverConnectionHandlerID, clientID, name, 512) == ERROR_ok) {
if (clientID == myClientID) { if (clientID == myClientID) {
curl = curl_easy_init(); //curl = curl_easy_init();
if (curl) { if (curl) {
if (status == STATUS_TALKING) { if (status == STATUS_TALKING) {
curl_easy_setopt(curl, CURLOPT_URL, LED_URL_SAVE); curl_easy_setopt(curl, CURLOPT_URL, LED_URL_SAVE);
@@ -867,7 +869,7 @@ void ts3plugin_onTalkStatusChangeEvent(uint64 serverConnectionHandlerID, int sta
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
} }
} }
curl_easy_cleanup(curl); //curl_easy_cleanup(curl);
} }
} }
} }
@@ -937,22 +939,23 @@ int ts3plugin_onClientPokeEvent(uint64 serverConnectionHandlerID, anyID fromClie
if(ffIgnored) { if(ffIgnored) {
return 0; /* Client will block anyways, doesn't matter what we return */ return 0; /* Client will block anyways, doesn't matter what we return */
} }
curl = curl_easy_init(); //curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, LED_URL_POKE); if (curl) {
res = curl_easy_perform(curl); curl_easy_setopt(curl, CURLOPT_URL, LED_URL_POKE);
Sleep(500); res = curl_easy_perform(curl);
res = curl_easy_perform(curl); Sleep(500);
Sleep(500); res = curl_easy_perform(curl);
res = curl_easy_perform(curl); Sleep(500);
Sleep(500); res = curl_easy_perform(curl);
res = curl_easy_perform(curl); Sleep(500);
Sleep(500); res = curl_easy_perform(curl);
Sleep(500);
curl_easy_setopt(curl, CURLOPT_URL, LED_URL_OFF);
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
curl_easy_setopt(curl, CURLOPT_URL, LED_URL_OFF);
res = curl_easy_perform(curl);
//curl_easy_cleanup(curl);
}
return 0; /* 0 = handle normally, 1 = client will ignore the poke */ return 0; /* 0 = handle normally, 1 = client will ignore the poke */
} }