Creating a new channel

To create a channel, set the various channel variables using ts3client_setChannelVariableAsInt and ts3client_setChannelVariableAsString. Pass zero as the channel ID parameter.

Then flush the changes to the server by calling:

unsigned int ts3client_flushChannelCreation(serverConnectionHandlerID,  
 channelParentID); 
uint64 serverConnectionHandlerID;
uint64 channelParentID;
 

Returns ERROR_ok on success, otherwise an error code as defined in public_errors.h.


After flushing the changes to the server, the following event will be called on successful channel creation:

void onNewChannelCreatedEvent(serverConnectionHandlerID,  
 channelID,  
 channelParentID,  
 invokerID,  
 invokerName,  
 invokerUniqueIdentifier); 
uint64 serverConnectionHandlerID;
uint64 channelID;
uint64 channelParentID;
anyID invokerID;
const char* invokerName;
const char* invokerUniqueIdentifier;
 


Example code to create a channel:

#define CHECK_ERROR(x) if((error = x) != ERROR_ok) { goto on_error; }

int createChannel(uint64 scHandlerID, uint64 parentChannelID, const char* name, const char* topic,
                  const char* description, const char* password, int codec, int codecQuality,
                  int maxClients, int familyMaxClients, int order, int perm,
                  int semiperm, int default) {
  unsigned int error;

  /* Set channel data, pass 0 as channel ID */
  CHECK_ERROR(ts3client_setChannelVariableAsString(scHandlerID, 0, CHANNEL_NAME, name));
  CHECK_ERROR(ts3client_setChannelVariableAsString(scHandlerID, 0, CHANNEL_TOPIC, topic));
  CHECK_ERROR(ts3client_setChannelVariableAsString(scHandlerID, 0, CHANNEL_DESCRIPTION, desc));
  CHECK_ERROR(ts3client_setChannelVariableAsString(scHandlerID, 0, CHANNEL_PASSWORD, password));
  CHECK_ERROR(ts3client_setChannelVariableAsInt   (scHandlerID, 0, CHANNEL_CODEC, codec));
  CHECK_ERROR(ts3client_setChannelVariableAsInt   (scHandlerID, 0, CHANNEL_CODEC_QUALITY, codecQuality));
  CHECK_ERROR(ts3client_setChannelVariableAsInt   (scHandlerID, 0, CHANNEL_MAXCLIENTS, maxClients));
  CHECK_ERROR(ts3client_setChannelVariableAsInt   (scHandlerID, 0, CHANNEL_MAXFAMILYCLIENTS, familyMaxClients));
  CHECK_ERROR(ts3client_setChannelVariableAsUInt64(scHandlerID, 0, CHANNEL_ORDER, order));
  CHECK_ERROR(ts3client_setChannelVariableAsInt   (scHandlerID, 0, CHANNEL_FLAG_PERMANENT, perm));
  CHECK_ERROR(ts3client_setChannelVariableAsInt   (scHandlerID, 0, CHANNEL_FLAG_SEMI_PERMANENT, semiperm));
  CHECK_ERROR(ts3client_setChannelVariableAsInt   (scHandlerID, 0, CHANNEL_FLAG_DEFAULT, default));

  /* Flush changes to server */
  CHECK_ERROR(ts3client_flushChannelCreation(scHandlerID, parentChannelID));
  return 0;  /* Success */

on_error:
  printf("Error creating channel: %d\n", error);
  return 1;  /* Failure */
}