3 #include "../ts3_sdk_3.0.2/include/public_errors.h" 4 #include "../ts3_sdk_3.0.2/include/clientlib_publicdefinitions.h" 5 #include "../ts3_sdk_3.0.2/include/clientlib.h" 26 case STATUS_DISCONNECTED:
27 if (errorNumber == ERROR_failed_connection_initialisation)
32 else if (errorNumber == ERROR_connection_lost)
34 teamSpeakInstance->
Log(
"onConnectStatusChangeEvent",
"Lost connection. We should reconnect, no?");
42 sprintf_s(msg, 199,
"Unhandled disconnect: %llu %d %x", static_cast<unsigned long long>(serverConnectionHandlerID), newStatus, errorNumber);
46 case STATUS_CONNECTING:
50 case STATUS_CONNECTED:
54 case STATUS_CONNECTION_ESTABLISHING:
58 case STATUS_CONNECTION_ESTABLISHED:
79 sprintf_s(msg, 199,
"%llu %llu %llu", static_cast<unsigned long long>(serverConnectionHandlerID), static_cast<unsigned long long>(channelID), static_cast<unsigned long long>(channelParentID));
82 if ((error = ts3client_getChannelVariableAsString(serverConnectionHandlerID, channelID, CHANNEL_NAME, &name)) == ERROR_ok)
84 sprintf_s(msg, 199,
"New channel: %llu %s", static_cast<unsigned long long>(channelID), name);
86 ts3client_freeMemory(name);
104 void TeamSpeak::onNewChannelCreatedEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID, anyID invokerID,
const char* invokerName,
const char* invokerUniqueIdentifier)
109 if (ts3client_getChannelVariableAsString(serverConnectionHandlerID, channelID, CHANNEL_NAME, &name) != ERROR_ok)
113 sprintf_s(msg, 199,
"New channel created: %s", name);
116 ts3client_freeMemory(name);
128 void TeamSpeak::onDelChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID,
const char* invokerName,
const char* invokerUniqueIdentifier)
131 sprintf_s(msg, 199,
"Channel ID %llu deleted by %s (%u)", static_cast<unsigned long long>(channelID), invokerName, invokerID);
146 void TeamSpeak::onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID,
int visibility,
const char* moveMessage)
149 sprintf_s(msg, 199,
"ClientID %u moves from channel %llu to %llu with message %s", clientID, static_cast<unsigned long long>(oldChannelID), static_cast<unsigned long long>(newChannelID), moveMessage);
169 if (ts3client_getClientVariableAsString(serverConnectionHandlerID, clientID, CLIENT_NICKNAME, &name) != ERROR_ok)
173 sprintf_s(msg, 199,
"New client: %s", name);
176 ts3client_freeMemory(name);
193 sprintf_s(msg, 199,
"ClientID %u timeouts with message %s", clientID, timeoutMessage);
212 if (ts3client_getClientVariableAsString(serverConnectionHandlerID, clientID, CLIENT_NICKNAME, &name) != ERROR_ok)
214 if (status == STATUS_TALKING)
216 sprintf_s(msg, 199,
"Client \"%s\" starts talking.", name);
220 sprintf_s(msg, 199,
"Client \"%s\" stops talking.", name);
224 ts3client_freeMemory(name);
242 if ((error = ts3client_allowWhispersFrom(serverConnectionHandlerID, clientID)) != ERROR_ok)
248 sprintf_s(msg, 199,
"Added client %d to whisper allow list", clientID);
252 void TeamSpeak::onServerErrorEvent(uint64 serverConnectionHandlerID,
const char* errorMessage,
unsigned int error,
const char* returnCode,
const char* extraMessage)
255 sprintf_s(msg, 199,
"Error for server %llu: %s (%x) %s", static_cast<unsigned long long>(serverConnectionHandlerID), errorMessage, error, extraMessage);
306 Log(
"Initialize",
"Entering...");
311 struct ClientUIFunctions funcs;
314 RtlZeroMemory(&funcs,
sizeof(
struct ClientUIFunctions));
336 if ((error = ts3client_initClientLib(&funcs,
nullptr, LogType_USERLOGGING,
nullptr,
"")) != ERROR_ok)
343 if ((error = ts3client_spawnNewServerConnectionHandler(0, &
scHandlerID)) != ERROR_ok)
345 Log(
"Initialize",
"ts3client_spawnNewServerConnectionHandler",
Logger::Error, error);
351 Log(
"Initialize", msg);
354 Log(
"Initialize",
"Enumerating capture modes...");
356 if ((error = ts3client_getCaptureModeList(&array)) == ERROR_ok)
358 for (
int i = 0; array[i] !=
nullptr; ++i)
360 sprintf_s(msg, 199,
"Available capture mode %i: %s", i, array[i]);
361 Log(
"Initialize", msg);
362 ts3client_freeMemory(array[i]);
364 ts3client_freeMemory(array);
372 Log(
"Initialize", msg);
375 sprintf_s(msg, 199,
"Capture device from configuration: %s",
config->
captureDevice.c_str());
376 Log(
"Initialize", msg);
379 Log(
"Initialize",
"Enumerating capture devices...");
381 if ((error = ts3client_getCaptureDeviceList(&
config->
captureMode, &array)) == ERROR_ok)
383 for (
int i = 0; array[i] !=
nullptr; ++i)
385 sprintf_s(msg, 199,
"Available capture device %s: %s", array[i][1], array[i][0]);
386 Log(
"Initialize", msg);
389 ts3client_freeMemory(array[i][0]);
390 ts3client_freeMemory(array[i][1]);
391 ts3client_freeMemory(array[i]);
393 ts3client_freeMemory(array);
401 Log(
"Initialize", msg);
412 error = ts3client_setPreProcessorConfigValue(
scHandlerID,
"denoise",
"false");
413 if (error != ERROR_ok)
415 Log(
"Initialize",
"ts3client_setPreProcessorConfigValue - denoise",
Logger::Error, error);
421 error = ts3client_setPreProcessorConfigValue(
scHandlerID,
"vad",
"false");
422 if (error != ERROR_ok)
424 Log(
"Initialize",
"ts3client_setPreProcessorConfigValue - vad",
Logger::Error, error);
431 error = ts3client_setPreProcessorConfigValue(
scHandlerID,
"voiceactivation_level", msg);
432 if (error != ERROR_ok)
434 Log(
"Initialize",
"ts3client_setPreProcessorConfigValue - voiceactivation_level",
Logger::Error, error);
437 error = ts3client_setPreProcessorConfigValue(
scHandlerID,
"agc",
"false");
438 if (error != ERROR_ok)
440 Log(
"Initialize",
"ts3client_setPreProcessorConfigValue - agc",
Logger::Error, error);
444 Log(
"Initialize", msg);
447 Log(
"Initialize",
"Enumerating playback modes...");
449 if (ts3client_getPlaybackModeList(&array) == ERROR_ok)
451 for (
int i = 0; array[i] !=
nullptr; ++i)
453 sprintf_s(msg, 199,
"Available playback mode %i: %s", i, array[i]);
454 Log(
"Initialize", msg);
455 ts3client_freeMemory(array[i]);
457 ts3client_freeMemory(array);
465 Log(
"Initialize", msg);
469 Log(
"Initialize", msg);
472 Log(
"Initialize",
"Enumerating playback devices...");
474 if ((error = ts3client_getPlaybackDeviceList(&
config->
playbackMode, &array)) == ERROR_ok)
476 for (
int i = 0; array[i] !=
nullptr; ++i)
478 sprintf_s(msg, 199,
"Available playback device %s: %s", array[i][1], array[i][0]);
479 Log(
"Initialize", msg);
482 ts3client_freeMemory(array[i][0]);
483 ts3client_freeMemory(array[i][1]);
484 ts3client_freeMemory(array[i]);
486 ts3client_freeMemory(array);
494 Log(
"Initialize", msg);
510 if ((error = ts3client_createIdentity(&identity)) != ERROR_ok)
520 sprintf_s(msgId, 999,
"You should configure this identity in your config.xml file: %s", identity);
523 ts3client_freeMemory(identity);
528 Log(
"Initialize",
"Finished!");
533 Log(
"dtor",
"Entering...");
538 if ((error = ts3client_stopConnection(
scHandlerID,
"leaving")) != ERROR_ok)
546 if ((error = ts3client_destroyServerConnectionHandler(
scHandlerID)) != ERROR_ok)
548 Log(
"dtor",
"ts3client_destroyServerConnectionHandler",
Logger::Error, error);
552 if ((error = ts3client_destroyClientLib()) != ERROR_ok)
557 Log(
"dtor",
"Finished!");
564 sprintf_s(newmsg, 199,
"TeamSpeak::%s %s", method, msg);
566 sprintf_s(newmsg, 199,
"TeamSpeak::%s", msg);
571 if (ts3client_getErrorMessage(errorno, &errormsg) == ERROR_ok)
573 strcat_s(newmsg, 199,
": ");
574 strcat_s(newmsg, 199, errormsg);
576 ts3client_freeMemory(errormsg);
594 if (command.
delay != 0.0f)
continue;
596 if (command.
name ==
"RtuTransmit")
609 error = ts3client_setClientSelfVariableAsInt(
scHandlerID, CLIENT_INPUT_DEACTIVATED, shouldTalk ? INPUT_ACTIVE : INPUT_DEACTIVATED);
610 if (error != ERROR_ok)
613 if (ts3client_getErrorMessage(error, &errorMsg) != ERROR_ok)
615 sprintf_s(msg, 999,
"Error toggling push-to-talk: %s\n", errorMsg);
617 ts3client_freeMemory(errorMsg);
621 if (ts3client_flushClientSelfUpdates(
scHandlerID,
nullptr) != ERROR_ok)
624 if (ts3client_getErrorMessage(error, &errorMsg) != ERROR_ok)
626 sprintf_s(msg, 999,
"Error flushing after toggling push-to-talk: %s\n", errorMsg);
628 ts3client_freeMemory(errorMsg);
static void onNewChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID)
std::vector< Command > commandStream
std::string captureDevice
static void onNewChannelCreatedEvent(uint64 serverConnectionHandlerID, uint64 channelID, uint64 channelParentID, anyID invokerID, const char *invokerName, const char *invokerUniqueIdentifier)
void Initialize(Logger *prmLogger, TeamSpeakConfig *prmConfig, Bus *prmBus)
void SetPTT(bool shouldTalk) const
static void onConnectStatusChangeEvent(uint64 serverConnectionHandlerID, int newStatus, unsigned int errorNumber)
TeamSpeak * teamSpeakInstance
global singleton because TeamSpeak doesn't support user context pointers
okay, the portable keyboard numbers don't work like the outside keypad because the outside keypad is ...
static void onClientMoveEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char *moveMessage)
void Log(char *method, const char *msg, Logger::Level level=Logger::Level::Info, int errorno=0) const
std::string name
command name
static void onIgnoredWhisperEvent(uint64 serverConnectionHandlerID, anyID clientID)
std::string playbackDevice
static void onTalkStatusChangeEvent(uint64 serverConnectionHandlerID, int status, int isReceivedWhisper, anyID clientID)
static void onUserLoggingMessageEvent(const char *logMessage, int logLevel, const char *logChannel, uint64 logID, const char *logTime, const char *completeLogString)
void Log(const char *msg, Level level=Info, int errorCode=0)
These have to be in this order.
static void onServerErrorEvent(uint64 serverConnectionHandlerID, const char *errorMessage, unsigned int error, const char *returnCode, const char *extraMessage)
static void onDelChannelEvent(uint64 serverConnectionHandlerID, uint64 channelID, anyID invokerID, const char *invokerName, const char *invokerUniqueIdentifier)
float delay
wait number of seconds before executing command
static void onClientMoveSubscriptionEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility)
static void onClientMoveTimeoutEvent(uint64 serverConnectionHandlerID, anyID clientID, uint64 oldChannelID, uint64 newChannelID, int visibility, const char *timeoutMessage)