Creating a new channel
| Interacting with the server |

### 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`;

Parameters

- `serverConnectionHandlerID`

  ID of the server connection handler to which the channel changes should be flushed.

- `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.

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`;

Parameters

- `serverConnectionHandlerID`

  ID of the server connection handler where the channel was created.

- `channelID`

  ID of the created channel. Channel IDs start with the value 1.

- `channelParentID`

  ID of the parent channel.

- `invokerID`

  ID of the client who requested the creation. If zero, the request was initiated by the server.

- `invokerName`

  Name of the client who requested the creation. If requested by the server, the name is empty.

- `invokerUniqueIdentifier`

  Unique ID of the client who requested the creation.

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_setChannelVariableAsInt   (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 */
    }

Interacting with the server |  | Deleting a channel