Disconnecting from a server

## Disconnecting from a server

To disconnect from a TeamSpeak 3 server call

`unsigned int ts3client_stopConnection(` | serverConnectionHandlerID, |
| quitMessage`)`; |

`anyID serverConnectionHandlerID`;
`const char* quitMessage`;

Parameters

- `serverConnectionHandlerID`

  The unique ID for this server connection handler.

- `quitMessage`

  A message like for example "leaving". The string needs to be encoded in UTF-8 format.

Returns `ERROR_ok` on success, otherwise an error code as defined in `public_errors.h`.

Like with connecting, on successful disconnecting the client will receive an event:

`void onConnectStatusChangeEvent(` | serverserverConnectionHandlerID, |
| newStatus, |
| errorNumber`)`; |

`anyID serverserverConnectionHandlerID`;
`int newStatus`;
`int errorNumber`;

Parameters

- `newStatus`

  Set to `STATUS_DISCONNECTED` as defined by the enum ConnectStatus.

- `errorNumber`

  `errorNumber` is expected to be `ERROR_ok` as response to calling `ts3client_stopConnection`.

  Values other than `ERROR_ok` occur when the connection has been lost for reasons not initiated by the user, e.g. network error, forcefully disconnected etc.

Should the server be shutdown, the follow event will be called:

`void onServerStopEvent(` | serverConnectionHandlerID, |
| shutdownMessage`)`; |

`anyID serverConnectionHandlerID`;
`const char* shutdownMessage`;

Parameters

- `serverConnectionHandlerID`

  Server connection handler ID of the stopped server.

- `shutdownMessage`

  Message announcing the reason for the shutdown sent by the server. Has to be encoded in UTF-8 format.

Connecting to a server |  | Error handling