TeamSpeak 3 SDK

Rename a Channel

Introduction

This article will guide you through change the channel variables on a TeamSpeak SDK server.

Let’s code

Topics:

  • Change channel variables
  • Example Code

Change channel variables

There are many varibales you can modify related to channels in the enum ChannelProperties.

enum ChannelProperties {
CHANNEL_NAME = 0, //Available for all channels that are "in view", always up-to-date
CHANNEL_TOPIC, //Available for all channels that are "in view", always up-to-date
CHANNEL_DESCRIPTION, //Must be requested (=> requestChannelDescription)
CHANNEL_PASSWORD, //not available client side
CHANNEL_CODEC, //Available for all channels that are "in view", always up-to-date
CHANNEL_CODEC_QUALITY, //Available for all channels that are "in view", always up-to-date
CHANNEL_MAXCLIENTS, //Available for all channels that are "in view", always up-to-date
CHANNEL_MAXFAMILYCLIENTS, //Available for all channels that are "in view", always up-to-date
CHANNEL_ORDER, //Available for all channels that are "in view", always up-to-date
CHANNEL_FLAG_PERMANENT, //Available for all channels that are "in view", always up-to-date
CHANNEL_FLAG_SEMI_PERMANENT, //Available for all channels that are "in view", always up-to-date
CHANNEL_FLAG_DEFAULT, //Available for all channels that are "in view", always up-to-date
CHANNEL_FLAG_PASSWORD, //Available for all channels that are "in view", always up-to-date
CHANNEL_CODEC_LATENCY_FACTOR, //Available for all channels that are "in view", always up-to-date
CHANNEL_CODEC_IS_UNENCRYPTED, //Available for all channels that are "in view", always up-to-date
CHANNEL_SECURITY_SALT, //Sets the options+salt for security hash (SDK only)
CHANNEL_DELETE_DELAY, //How many seconds to wait before deleting this channel
CHANNEL_ENDMARKER,
};

To modify, you will need ts3server_setChannelVariableAsInt and ts3server_setChannelVariableAsString:

unsigned int ts3server_setChannelVariableAsInt(serverID, channelID, flag, value);
uint64 serverID;
uint64 channelID;
ChannelProperties flag;
int value;
unsigned int ts3server_setChannelVariableAsString(serverID, channelID, flag, value);
uint64 serverID;
uint64 channelID;
ChannelProperties flag;
const char* value;
  • serverConnectionHandlerID ID of the virtual server on which the information for the specified channel should be changed.
  • channelID ID of the channel whoses property should be changed.
  • flag Channel propery to change, see above.
  • value Value the channel property should be changed to.

After modifying one or more channel variables, you must flush the changes.

unsigned int ts3server_flushChannelVariable(serverID, channelID);
uint64 serverID;
uint64 channelID;

Example Code

Now we’re ready to change the name of a channel on the TeamSpeak SDK Server.

First set the channel variables:

uint64 server_id;
unsigned int channel_id;
unsigned int error;
if ((error = ts3server_setChannelVariableAsString(server_id, channel_id, CHANNEL_NAME, "New channel name")) != ERROR_ok)
{
    printf("Error setting channel name variable: %d\n", error);
}

Note: In contrast to the channel creation, we must specify the channel id, of the channel we want to modify, here

Now you can flush the changes:

uint64 server_id;
unsigned int channel_id;
if ((error = ts3server_flushChannelVariable(serverID, channel_id)) != ERROR_ok)
{
    printf("Error change channel variables: %d\n", error);
}

Congratulations!

You have change your first channel name on a TeamSpeak Server using the TeamSpeak SDK and have learned the basics of channel variables.