37 lines
7.9 KiB
HTML
37 lines
7.9 KiB
HTML
<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Creating a new channel</title><link rel="stylesheet" href="ts3doc.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.74.0"><link rel="home" href="index.html" title="TeamSpeak 3 Client SDK Developer Manual"><link rel="up" href="ar01s23.html" title="Interacting with the server"><link rel="prev" href="ar01s23.html" title="Interacting with the server"><link rel="next" href="ar01s23s03.html" title="Deleting a channel"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><img id="logo" src="images/logo.png"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Creating a new channel</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ar01s23.html"><img src="images/prev.png" alt="Prev"></a> </td><th width="60%" align="center">Interacting with the server</th><td width="20%" align="right"> <a accesskey="n" href="ar01s23s03.html"><img src="images/next.png" alt="Next"></a></td></tr></table><hr></div><div class="section" lang="en"><div class="titlepage"><div><div><h3 class="title"><a name="createchannel"></a>Creating a new channel</h3></div></div></div><p>To create a channel, set the various channel variables using <a class="link" href="ar01s22s02.html#setchannelvarasint"><code class="function">ts3client_setChannelVariableAsInt</code></a> and <a class="link" href="ar01s22s02.html#setchannelvarasstring"><code class="function">ts3client_setChannelVariableAsString</code></a>. Pass zero as the channel ID parameter.</p><p>Then flush the changes to the server by calling:
|
||
</p><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">unsigned int <b class="fsfunc">ts3client_flushChannelCreation</b>(</code></td><td><var class="pdparam">serverConnectionHandlerID</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">channelParentID</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>uint64 <var class="pdparam">serverConnectionHandlerID</var></code>;<br><code>uint64 <var class="pdparam">channelParentID</var></code>;</div><div class="funcprototype-spacer"> </div></div><p>
|
||
<a class="indexterm" name="idm44835433470832"></a></p><div class="itemizedlist"><ul type="disc"><li><p><em class="parameter"><code>serverConnectionHandlerID</code></em></p><p>ID of the server connection handler to which the channel changes should be flushed.</p></li><li><p><em class="parameter"><code>channelParentID</code></em></p><p>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.</p></li></ul></div><p>Returns <em class="structfield"><code>ERROR_ok</code></em> on success, otherwise an error code as defined in <code class="filename">public_errors.h</code>.</p><div class="literallayout"><p><br>
|
||
</p></div><p>After flushing the changes to the server, the following event will be called on successful channel creation:
|
||
</p><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">onNewChannelCreatedEvent</b>(</code></td><td><var class="pdparam">serverConnectionHandlerID</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">channelID</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">channelParentID</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">invokerID</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">invokerName</var>, </td><td> </td></tr><tr><td> </td><td><var class="pdparam">invokerUniqueIdentifier</var><code>)</code>;</td><td> </td></tr></table><div class="paramdef-list"><code>uint64 <var class="pdparam">serverConnectionHandlerID</var></code>;<br><code>uint64 <var class="pdparam">channelID</var></code>;<br><code>uint64 <var class="pdparam">channelParentID</var></code>;<br><code>anyID <var class="pdparam">invokerID</var></code>;<br><code>const char* <var class="pdparam">invokerName</var></code>;<br><code>const char* <var class="pdparam">invokerUniqueIdentifier</var></code>;</div><div class="funcprototype-spacer"> </div></div><p>
|
||
<a class="indexterm" name="idm44835433458080"></a></p><div class="itemizedlist"><ul type="disc"><li><p><em class="parameter"><code>serverConnectionHandlerID</code></em></p><p>ID of the server connection handler where the channel was created.</p></li><li><p><em class="parameter"><code>channelID</code></em></p><p>ID of the created channel. Channel IDs start with the value 1.</p></li><li><p><em class="parameter"><code>channelParentID</code></em></p><p>ID of the parent channel.</p></li><li><p><em class="parameter"><code>invokerID</code></em></p><p>ID of the client who requested the creation. If zero, the request was initiated by the server.</p></li><li><p><em class="parameter"><code>invokerName</code></em></p><p>Name of the client who requested the creation. If requested by the server, the name is empty.</p></li><li><p><em class="parameter"><code>invokerUniqueIdentifier</code></em></p><p>Unique ID of the client who requested the creation.</p></li></ul></div><div class="literallayout"><p><br>
|
||
</p></div><p>Example code to create a channel:</p><pre class="programlisting">#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 */
|
||
}</pre></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ar01s23.html"><img src="images/prev.png" alt="Prev"></a> </td><td width="20%" align="center"><a accesskey="u" href="ar01s23.html"><img src="images/up.png" alt="Up"></a></td><td width="40%" align="right"> <a accesskey="n" href="ar01s23s03.html"><img src="images/next.png" alt="Next"></a></td></tr><tr><td width="40%" align="left" valign="top">Interacting with the server </td><td width="20%" align="center"><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a></td><td width="40%" align="right" valign="top"> Deleting a channel</td></tr></table></div></body></html>
|