Search code examples
phpteamspeakts3phpframework

Teamspeak Framework Documentation Explanation


Im using the TS Framework to read out some data through the Teamspeak Query in PHP. But the documentation is horrible!

To display all IPs from all clients I use this code:

foreach($ts3_VirtualServer->clientList() as $client)
{
    // skip query clients
    if($client["client_type"]) continue;

    $clientInfo = $client->getInfo();
    echo $clientInfo['connection_client_ip'] . "<br>";
} 

(it's not the full code)

Where is the part in the documentation which says what getInfo() returns?

Documentation Link


Solution

  • It's not in the documentation since it's abstract / generalized for all node objects.

    As you can see from TeamSpeak3_Node_Abstract::getInfo():

    if ($extend) {
      $this->fetchNodeInfo();
    }
    
    if ($convert) {
      $info = $this->nodeInfo;
    
      foreach ($info as $key => $val) {
        $key = TeamSpeak3_Helper_String::factory($key);
        //...
      }
    
      return $info;
    }
    
    return $this->nodeInfo;
    

    The data returned (formatted or directly) is TeamSpeak3_Node_Abstract::$nodeInfo.

    Searching GitHub repo for nodeInfo = shows how several of the (child) Nodes set their inherited nodeInfo property.

    For example, we have TeamSpeak3_Node_Host::fetchNodeInfo() which uses properties returned by TeamSpeak3 Server Query commands hostinfo, instanceinfo:

    protected function fetchNodeInfo() {
      $info1          = $this->request("hostinfo")->toList();
      $info2          = $this->request("instanceinfo")->toList();
      $this->nodeInfo = array_merge($this->nodeInfo, $info1, $info2);
    }
    

    Also, for example, TeamSpeak3_Node_Server::fetchNodeInfo() which uses properties returned by serverinfo command:

    protected function fetchNodeInfo() {
      $this->nodeInfo = array_merge($this->nodeInfo,
        $this->request("serverinfo")->toList());
    }
    

    As you can imagine, several TeamSpeak3 objects have a corresponding *info command which returns that object's properties.

    You can view several example results of these commands, along with properties returned, in the TeamSpeak3 Server Query manual. Here for example, the serverinfo command.

    Also, at the end of the manual, you can find several list of object properties. For example, the virtual server properties.