Introduction

This document describes server-side programming with the TeamSpeak 3 SDK. The SDK user will be able to create a custom TeamSpeak 3 server binary using the provided server API and library.

System requirements

For developing third-party servers with the TeamSpeak 3 Server Lib the following system requirements apply:

  • Windows 7, 8.1, 10

  • Mac OS X 10.6 and above

  • Any recent Linux distribution with libstdc++ 6

Important

The calling convention used in the functions exported by the shared TeamSpeak 3 SDK libaries is cdecl. You must not use another calling convention, like stdcall on Windows, when declaring function pointers to the TeamSpeak 3 SDK libraries. Otherwise stack corruption at runtime may occur.

Usage

All the required files are located in the bin directory of the TeamSpeak 3 SDK distribution.

Note

The license file licensekey.dat needs to be located in the same folder as your server executable.

If no license key is present, the server will run with the following limitations:

  • One server process per machine

  • One virtual server per process

  • Limited to 32 slots maximum

For more detailed information about licensing of TeamSpeak 3 servers or to obtain a license, please contact sales@teamspeakusa.com.

Calling Server lib functions

Server library functions follow a common pattern. They always return a value from the Ts3ErrorType enum, which indicates success (ERROR_ok) or an error. If there is a result variable, it is always the last variable in the parameter list.

ERROR ts3server_FUNCNAME(arg1, arg2, ..., &result);

Result variables should only be accessed if the function returned ERROR_ok. Otherwise the state of the result variable is undefined.

In those cases where the result variable is a basic type (int, float etc.), the memory for the result variable has to be declared by the caller. Simply pass the address of the variable to the Server Lib function ts3server_freeMemory().

int result;

if (ts3server_XXX(arg1, arg2, ..., &result) == ERROR_ok) {
    /* Use result variable */
} else {
    /* Handle error, result variable is undefined */
}

If the result variable is a pointer type (C strings, arrays etc.), the memory is allocated by the Server Lib function. In this case, the caller has to release the allocated memory later by using ts3server_freeMemory() except when stated otherwise.

It is important to only access and release the memory if the function returned ERROR_ok. Should the function return an error, the result variable is uninitialized, so freeing or accessing it could crash the application.

char* result;

if (ts3server_XXX(arg1, arg2, ..., &result) == ERROR_ok) {
    /* Use result variable */
    ts3server_freeMemory(result);  /* Release result variable */
} else {
    /* Handle error, result variable is undefined. Do not access or release it. */
}

Note

Server Lib functions are thread-safe. It is possible to access the Server Lib from several threads at the same time.