TeamSpeak 3 PHP Framework  1.1.12
TeamSpeak3_Adapter_Update Class Reference

Provides methods to query the latest TeamSpeak 3 build numbers from the master server. More...

Inheritance diagram for TeamSpeak3_Adapter_Update:
TeamSpeak3_Adapter_Abstract

List of all members.

Public Member Functions

 syn ()
 Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote server.
 __destruct ()
 The TeamSpeak3_Adapter_Update destructor.
 getRev ($channel="stable")
 Returns the current build number for a specified update channel.
 getVersion ($channel="stable")
 Returns the current version string for a specified update channel.
 getClientRev ()
 Alias for getRev() using the 'stable' update channel.
 getServerRev ()
 Alias for getRev() using the 'server' update channel.
 getClientVersion ()
 Alias for getVersion() using the 'stable' update channel.
 getServerVersion ()
 Alias for getVersion() using the 'server' update channel.
 __sleep ()
 Commit pending data.
 __wakeup ()
 Reconnects to the remote server.
 getProfiler ()
 Returns the profiler timer used for this connection adapter.
 getTransport ()
 Returns the transport object used for this connection adapter.
 getTransportHost ()
 Returns the hostname or IPv4 address the underlying TeamSpeak3_Transport_Abstract object is connected to.
 getTransportPort ()
 Returns the port number of the server the underlying TeamSpeak3_Transport_Abstract object is connected to.

Protected Member Functions

 initTransport ($options, $transport="TeamSpeak3_Transport_TCP")
 Loads the transport object object used for the connection adapter and passes a given set of options.

Protected Attributes

 $default_host = "update.teamspeak.com"
 $default_port = 17384
 $build_datetimes = null
 $version_strings = null
 $options = null
 $transport = null

Detailed Description

Provides methods to query the latest TeamSpeak 3 build numbers from the master server.

Definition at line 32 of file Update.php.


Constructor & Destructor Documentation

The TeamSpeak3_Adapter_Update destructor.

Returns:
void

Reimplemented from TeamSpeak3_Adapter_Abstract.

Definition at line 97 of file Update.php.

References TeamSpeak3_Adapter_Abstract\getTransport().

  {
    if($this->getTransport() instanceof TeamSpeak3_Transport_Abstract && $this->getTransport()->isConnected())
    {
      $this->getTransport()->disconnect();
    }
  }

Member Function Documentation

Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote server.

Exceptions:
TeamSpeak3_Adapter_Update_Exception
Returns:
void

Reimplemented from TeamSpeak3_Adapter_Abstract.

Definition at line 69 of file Update.php.

References TeamSpeak3_Helper_String\fromHex(), TeamSpeak3_Helper_Signal\getInstance(), TeamSpeak3_Adapter_Abstract\getTransport(), TeamSpeak3_Helper_Profiler\init(), and TeamSpeak3_Adapter_Abstract\initTransport().

  {
    if(!isset($this->options["host"]) || empty($this->options["host"])) $this->options["host"] = $this->default_host;
    if(!isset($this->options["port"]) || empty($this->options["port"])) $this->options["port"] = $this->default_port;

    $this->initTransport($this->options, "TeamSpeak3_Transport_UDP");
    $this->transport->setAdapter($this);

    TeamSpeak3_Helper_Profiler::init(spl_object_hash($this));

    $this->getTransport()->send(TeamSpeak3_Helper_String::fromHex(33));

    if(!preg_match_all("/,?(\d+)#([0-9a-zA-Z\._-]+),?/", $this->getTransport()->read(96), $matches) || !isset($matches[1]) || !isset($matches[2]))
    {
      throw new TeamSpeak3_Adapter_Update_Exception("invalid reply from the server");
    }

    $this->build_datetimes = $matches[1];
    $this->version_strings = $matches[2];

    TeamSpeak3_Helper_Signal::getInstance()->emit("updateConnected", $this);
  }
TeamSpeak3_Adapter_Update::getRev ( channel = "stable")

Returns the current build number for a specified update channel.

Note that since version 3.0.0, the build number represents an integer timestamp. $channel must be set to one of the following values:

  • stable
  • beta
  • alpha
  • server
Parameters:
string$channel
Exceptions:
TeamSpeak3_Adapter_Update_Exception
Returns:
integer

Definition at line 119 of file Update.php.

Referenced by getClientRev(), and getServerRev().

  {
    switch($channel)
    {
      case "stable":
        return isset($this->build_datetimes[0]) ? $this->build_datetimes[0] : null;

      case "beta":
        return isset($this->build_datetimes[1]) ? $this->build_datetimes[1] : null;

      case "alpha":
        return isset($this->build_datetimes[2]) ? $this->build_datetimes[2] : null;

      case "server":
        return isset($this->build_datetimes[3]) ? $this->build_datetimes[3] : null;

      default:
        throw new TeamSpeak3_Adapter_Update_Exception("invalid update channel identifier (" . $channel . ")");
    }
  }
TeamSpeak3_Adapter_Update::getVersion ( channel = "stable")

Returns the current version string for a specified update channel.

$channel must be set to one of the following values:

  • stable
  • beta
  • alpha
  • server
Parameters:
string$channel
Exceptions:
TeamSpeak3_Adapter_Update_Exception
Returns:
integer

Definition at line 153 of file Update.php.

Referenced by getClientVersion(), and getServerVersion().

  {
    switch($channel)
    {
      case "stable":
        return isset($this->version_strings[0]) ? $this->version_strings[0] : null;

      case "beta":
        return isset($this->version_strings[1]) ? $this->version_strings[1] : null;

      case "alpha":
        return isset($this->version_strings[2]) ? $this->version_strings[2] : null;

      case "server":
        return isset($this->version_strings[3]) ? $this->version_strings[3] : null;

      default:
        throw new TeamSpeak3_Adapter_Update_Exception("invalid update channel identifier (" . $channel . ")");
    }
  }

Alias for getRev() using the 'stable' update channel.

Parameters:
string$channel
Returns:
integer

Definition at line 180 of file Update.php.

References getRev().

  {
    return $this->getRev("stable");
  }

Alias for getRev() using the 'server' update channel.

Parameters:
string$channel
Returns:
integer

Definition at line 191 of file Update.php.

References getRev().

  {
    return $this->getRev("server");
  }

Alias for getVersion() using the 'stable' update channel.

Parameters:
string$channel
Returns:
integer

Definition at line 202 of file Update.php.

References getVersion().

  {
    return $this->getVersion("stable");
  }

Alias for getVersion() using the 'server' update channel.

Parameters:
string$channel
Returns:
integer

Definition at line 213 of file Update.php.

References getVersion().

  {
    return $this->getVersion("server");
  }

Commit pending data.

Returns:
array

Definition at line 85 of file Abstract.php.

  {
    return array("options");
  }

Reconnects to the remote server.

Returns:
void

Definition at line 95 of file Abstract.php.

References TeamSpeak3_Adapter_Abstract\syn().

  {
    $this->syn();
  }
TeamSpeak3_Adapter_Abstract::initTransport ( options,
transport = "TeamSpeak3_Transport_TCP" 
) [protected, inherited]

Loads the transport object object used for the connection adapter and passes a given set of options.

Parameters:
array$options
string$transport
Exceptions:
TeamSpeak3_Adapter_Exception
Returns:
void

Definition at line 129 of file Abstract.php.

Referenced by TeamSpeak3_Adapter_FileTransfer\syn(), TeamSpeak3_Adapter_TSDNS\syn(), TeamSpeak3_Adapter_Blacklist\syn(), TeamSpeak3_Adapter_ServerQuery\syn(), and syn().

  {
    if(!is_array($options))
    {
      throw new TeamSpeak3_Adapter_Exception("transport parameters must provided in an array");
    }

    $this->transport = new $transport($options);
  }

Returns the hostname or IPv4 address the underlying TeamSpeak3_Transport_Abstract object is connected to.

Returns:
string

Definition at line 145 of file Abstract.php.

References TeamSpeak3_Adapter_Abstract\getTransport().

  {
    return $this->getTransport()->getConfig("host", "0.0.0.0");
  }

Returns the port number of the server the underlying TeamSpeak3_Transport_Abstract object is connected to.

Returns:
string

Definition at line 156 of file Abstract.php.

References TeamSpeak3_Adapter_Abstract\getTransport().

  {
    return $this->getTransport()->getConfig("port", "0");
  }

The documentation for this class was generated from the following file:
 All Classes Files Functions Variables