Text chat

In addition to voice chat, TeamSpeak 3 allows clients to communicate via text chat. Valid targets can be a client, channel or an entire virtual server.

Sending

Depending on the target, there are three functions to send text messages.

Private

To send a private text message to a single client use

unsigned int ts3client_requestSendPrivateTextMsg(uint64 serverConnectionHandlerID, const char *message, anyID targetClientID, const char *returnCode)

Send a private chat message to a client.

You will receive an onServerErrorEvent with the passed returnCode indicating whether or not the operation was successful.

Parameters:
  • serverConnectionHandlerID – the connection handler on which to send the message

  • message – a utf8 encoded c string with the text to send

  • targetClientID – the client id of the client to send the message to

  • returnCode – a c string to identify this request in callbacks. Pass an empty string if unused.

Returns:

An Error code from the Ts3ErrorType enum indicating either success or the failure reason

Channel

To send a message to all clients that are in the specified channel at the time

unsigned int ts3client_requestSendChannelTextMsg(uint64 serverConnectionHandlerID, const char *message, uint64 targetChannelID, const char *returnCode)

Send a text message to your current channel.

You will receive an onServerErrorEvent with the passed returnCode indicating whether or not the operation was successful.

Parameters:
  • serverConnectionHandlerID – the connection handler on which to send the message

  • message – a utf8 encoded c string with the text to send

  • targetChannelID – the channel to send the message to. IGNORED.

  • returnCode – a c string to identify this request in callbacks. Pass an empty string if unused.

Returns:

An Error code from the Ts3ErrorType enum indicating either success or the failure reason

Server

These messages will be received by everyone that is connected to the virtual server.

unsigned int ts3client_requestSendServerTextMsg(uint64 serverConnectionHandlerID, const char *message, const char *returnCode)

Send a text message to the server chat.

You will receive an onServerErrorEvent with the passed returnCode indicating whether or not the operation was successful.

Parameters:
  • serverConnectionHandlerID – the connection handler on which to send the message

  • message – a utf8 encoded c string with the text to send

  • returnCode – a c string to identify this request in callbacks. Pass an empty string if unused.

Returns:

An Error code from the Ts3ErrorType enum indicating either success or the failure reason

Example

Example to send a text chat to a client with ID 123:

1const char *msg = "Hello TeamSpeak!";
2anyID targetClientID = 123;
3
4if (ts3client_requestSendPrivateTextMsg(scHandlerID, msg, targetClient, NULL) != ERROR_ok) {
5  /* Handle error */
6}

Receiving

Regardless of where the message was sent (client, channel or the entire server) every client that receives the message will have the following callback called

struct ClientUIFunctions

Defines available callbacks that you can receive.

Set the members of this struct to a function to call when the specific event happens.

Public Members

void (*onTextMessageEvent)(uint64 serverConnectionHandlerID, anyID targetMode, anyID toID, anyID fromID, const char *fromName, const char *fromUniqueIdentifier, const char *message)

called when a text message was received

Param serverConnectionHandlerID:

specifies on which connection the callback was called

Param targetMode:

identifies the type of the message. One of the values from the TextMessageTargetMode enum.

Param toID:

the id of the recipient. Depends on the value of targetMode. a channel id for channel chat, own client id for private messages, 0 for server messages

Param fromID:

id of the client that sent the message

Param fromName:

utf8 encoded c string containing the display name of the client sending the message

Param fromUniqueIdentifier:

utf8 encoded c string containing the public identity of the sending client

Param message:

utf8 encoded c string containing the actual message