This native Node.js addon is a wrapper for the TeamSpeak 3 SDK and allows JavaScript implementations of third-party clients using the TeamSpeak 3 ClientLib.
The following prerequisites are necessary prior to using the addon:
All dependencies can be installed via npm
:
npm install
This will also build build the module for your current platform. If you want to build the addon manually, issue the following commands in the root directory after cloning the repository:
$ node-gyp configure
$ node-gyp build
Included is a minimal console client to connect to a local TeamSpeak 3 SDK Server.
$ cd node-ts3sdk-client
$ node examples/client_minimal.js
Please refer to the official TeamSpeak 3 SDK documentation for a list of functions and events available.
After loading the addon, most TeamSpeak 3 ClientLib features are available in JavaScript. For the sake of convenience the ts3client_
prefix has been removed from function names and some arguments are optional.
const ts3client = require('node-ts3sdk-client');
ts3client.initClientLib(ts3client.LogTypes.CONSOLE, logPath, soundBackendPath);
var schID = ts3client.spawnNewServerConnectionHandler();
var ident = ts3client.createIdentity();
ts3client.startConnection(schID, ident, '127.0.0.1', 9987, 'JohnDoe');
To register a callback to an event triggered by the TeamSpeak 3 ClientLib, use the on
method:
ts3client.on('onConnectStatusChangeEvent', function(schID, status, errno)
{
// your code
});
ts3client.on('onTalkStatusChangeEvent', function(schID, status, isWhisper, clientID)
{
// your code
});
ts3client.on('onClientMoveEvent', function(schID, clientID, oldChannelID, newChannelID, visibility, moveMessage)
{
// your code
});
When an error occurs, the addon will throw exceptions:
try
{
ts3client.openCaptureDevice(schID, undefined, 'some_invalid_capture_device');
}
catch(err)
{
var errno = ts3client.getLastError();
console.log('ERROR ' + errno + ': ' + err.message);
}
I am aware that some features of the SDK are not implemented and I am working to update these. Please visit the project on GitHub to view outstanding issues.