This article will guide you through creating your first own channel on a TeamSpeak SDK server.
This Hello World application will be able to host connections for TeamSpeak SDK clients with a second channel.
Topics:
To create a channel, first set the desired channel variables using ts3server_setChannelVariableAsInt
and ts3server_setChannelVariableAsString
. Pass zero as the channel ID parameter.
unsigned int ts3server_setChannelVariableAsInt(
uint64 serverID,
uint64 channelID,
enum ChannelProperties flag,
int value);
unsigned int ts3server_setChannelVariableAsString(
uint64 serverID,
uint64 channelID,
enum ChannelProperties flag,
const char* value);
Next send the request to the server by calling ts3server_flushChannelCreation
.
unsigned int ts3server_flushChannelCreation(
uint64 serverID,
uint64 channelParentID,
uint64* result);
serverID:
ID of the virtual server on which that channel should be created.
channelParentID:
ID of the parent channel, if the new channel is to be created as subchannel. Pass zero if the channel should be created as top-level channel.
result:
Address of a variable that receives the ID of the newly created channel.
Now we’re ready to create the channel on the TeamSpeak SDK Server.
First set the channel data:
unsigned int error;
if ((error = ts3server_setChannelVariableAsString(serverID, 0, CHANNEL_NAME, "Test channel name")) != ERROR_ok){
printf("Error setting channel name variable: %d\n", error);}
if ((error = ts3server_setChannelVariableAsString(serverID, 0, CHANNEL_TOPIC, "Test channel topic")) != ERROR_ok){
printf("Error setting channel topic variable: %d\n", error); }
if ((error = ts3server_setChannelVariableAsString(serverID, 0, CHANNEL_DESCRIPTION, "Test channel description")) != ERROR_ok){
printf("Error setting channel description variable: %d\n", error); }
if ((error = ts3server_setChannelVariableAsInt(serverID, 0, CHANNEL_FLAG_PERMANENT, 1)) != ERROR_ok){
printf("Error setting channel flag permanent variable: %d\n", error); }
if ((error = ts3server_setChannelVariableAsInt(serverID, 0, CHANNEL_FLAG_SEMI_PERMANENT, 0)) != ERROR_ok){
printf("Error setting channel semi permanent variable: %d\n", error); }
Then initiate the channel creation:
uint64 server_id;
unsigned int channelID;
unsigned int error;
if ((error = ts3server_flushChannelCreation(serverID, 0, &channelID)) != ERROR_ok)
{
printf("Error Creating Channel: %d\n", error);
}
You have created your first channel on a Teamspeak server using the TeamSpeak SDK and have learned the basics channel creation.