Hello
I added functions to code of this module. Whit this code suspend and unsuspend works fine, please check it:
Teamspeak.php suspend function:
public function suspendService($package, $service, $parent_package = null, $parent_service = null)
{
$row = $this->getModuleRow();
$api = $this->getApi(
$row->meta->hostname,
$row->meta->username,
$row->meta->password,
$row->meta->port
);
if (!$row) {
$this->Input->setErrors(
['module_row' => ['missing' => Language::_('Teamspeak.!error.module_row.missing', true)]]
);
return;
}
// Get service parameters
$service_fields = $this->serviceFieldsToObject($service->fields);
// Modify "virtualserver_autostart" to 0
$this->parseResponse($api->suspendServer($service_fields->teamspeak_sid));
// Stop server
$this->parseResponse($api->stopServer($service_fields->teamspeak_sid));
return null;
}
Teamspeak.php unsuspend function:
public function unsuspendService($package, $service, $parent_package = null, $parent_service = null)
{
$row = $this->getModuleRow();
$api = $this->getApi(
$row->meta->hostname,
$row->meta->username,
$row->meta->password,
$row->meta->port
);
if (!$row) {
$this->Input->setErrors(
['module_row' => ['missing' => Language::_('Teamspeak.!error.module_row.missing', true)]]
);
return;
}
// Get service parameters
$service_fields = $this->serviceFieldsToObject($service->fields);
// Modify "virtualserver_autostart" to 1
$this->parseResponse($api->unsuspendServer($service_fields->teamspeak_sid));
// Start server
$this->parseResponse($api->startServer($service_fields->teamspeak_sid));
return null;
}
These codes call two new functions in teamspeak_api.php:
teamspeak_api.php suspendserver function:
public function suspendServer($sid)
{
try {
// Build the parameters array
$api_params = [
'virtualserver_autostart' => 0
];
// Fetch the virtual server instance, and modify it
$instance = $this->apiRequest('serverquery')->serverList()[$sid];
$result = $instance->modify($api_params);
// Add a control variable to know if the API request has been send successfully
if (empty($result['error'])) {
$result['status'] = true;
}
} catch (Exception $e) {
$result = [
'error' => $e->getMessage(),
'status' => false,
'code' => $e->getCode()
];
}
return (object) $result;
}
teamspeak_api.php unsuspendserver function:
public function unsuspendServer($sid)
{
try {
// Build the parameters array
$api_params = [
'virtualserver_autostart' => 1
];
// Fetch the virtual server instance, and modify it
$instance = $this->apiRequest('serverquery')->serverList()[$sid];
$result = $instance->modify($api_params);
// Add a control variable to know if the API request has been send successfully
if (empty($result['error'])) {
$result['status'] = true;
}
} catch (Exception $e) {
$result = [
'error' => $e->getMessage(),
'status' => false,
'code' => $e->getCode()
];
}
return (object) $result;
}
That is all, i attached file if someone wants to donwnload it
teamspeak.php
teamspeak_api.php