TeamSpeak 3 PHP Framework
1.1.12
|
Abstract class for connecting to a TeamSpeak 3 Server through different ways of transport. More...
Public Member Functions | |
__construct (array $config) | |
The TeamSpeak3_Transport_Abstract constructor. | |
__sleep () | |
Commit pending data. | |
__wakeup () | |
Reconnects to the remote server. | |
__destruct () | |
The TeamSpeak3_Transport_Abstract destructor. | |
connect () | |
Connects to a remote server. | |
disconnect () | |
Disconnects from a remote server. | |
read ($length=4096) | |
Reads data from the stream. | |
send ($data) | |
Writes data to the stream. | |
getStream () | |
Returns the underlying stream resource. | |
getConfig ($key=null, $default=null) | |
Returns the configuration variables in this adapter. | |
setAdapter (TeamSpeak3_Adapter_Abstract $adapter) | |
Sets the TeamSpeak3_Adapter_Abstract object using this transport. | |
getAdapter () | |
Returns the TeamSpeak3_Adapter_Abstract object using this transport. | |
getAdapterType () | |
Returns the adapter type. | |
getMetaData () | |
Returns header/meta data from stream pointer. | |
isConnected () | |
Returns TRUE if the transport is connected. | |
Protected Member Functions | |
waitForReadyRead ($time=0) | |
Blocks a stream until data is available for reading if the stream is connected in non-blocking mode. | |
Protected Attributes | |
$config = null | |
$stream = null | |
$adapter = null |
Abstract class for connecting to a TeamSpeak 3 Server through different ways of transport.
Definition at line 32 of file Abstract.php.
TeamSpeak3_Transport_Abstract::__construct | ( | array $ | config | ) |
The TeamSpeak3_Transport_Abstract constructor.
array | $config |
TeamSpeak3_Transport_Exception |
Definition at line 62 of file Abstract.php.
{ if(!array_key_exists("host", $config)) { throw new TeamSpeak3_Transport_Exception("config must have a key for 'host' which specifies the server host name"); } if(!array_key_exists("port", $config)) { throw new TeamSpeak3_Transport_Exception("config must have a key for 'port' which specifies the server port number"); } if(!array_key_exists("timeout", $config)) { $config["timeout"] = 10; } if(!array_key_exists("blocking", $config)) { $config["blocking"] = 1; } $this->config = $config; }
The TeamSpeak3_Transport_Abstract destructor.
Definition at line 112 of file Abstract.php.
References disconnect().
{ if($this->adapter instanceof TeamSpeak3_Adapter_Abstract) { $this->adapter->__destruct(); } $this->disconnect(); }
Commit pending data.
Definition at line 92 of file Abstract.php.
{ return array("config"); }
Reconnects to the remote server.
Definition at line 102 of file Abstract.php.
References connect().
{ $this->connect(); }
TeamSpeak3_Transport_Abstract::connect | ( | ) | [abstract] |
Connects to a remote server.
TeamSpeak3_Transport_Exception |
Reimplemented in TeamSpeak3_Transport_TCP, and TeamSpeak3_Transport_UDP.
Referenced by __wakeup().
TeamSpeak3_Transport_Abstract::disconnect | ( | ) | [abstract] |
Disconnects from a remote server.
Reimplemented in TeamSpeak3_Transport_TCP, and TeamSpeak3_Transport_UDP.
Referenced by __destruct().
TeamSpeak3_Transport_Abstract::read | ( | $ | length = 4096 | ) | [abstract] |
Reads data from the stream.
integer | $length |
TeamSpeak3_Transport_Exception |
Reimplemented in TeamSpeak3_Transport_TCP, and TeamSpeak3_Transport_UDP.
TeamSpeak3_Transport_Abstract::send | ( | $ | data | ) | [abstract] |
Writes data to the stream.
string | $data |
Reimplemented in TeamSpeak3_Transport_TCP, and TeamSpeak3_Transport_UDP.
Returns the underlying stream resource.
Definition at line 159 of file Abstract.php.
{
return $this->stream;
}
TeamSpeak3_Transport_Abstract::getConfig | ( | $ | key = null , |
$ | default = null |
||
) |
Returns the configuration variables in this adapter.
string | $key | |
mixed | $default |
Definition at line 171 of file Abstract.php.
{ if($key !== null) { return array_key_exists($key, $this->config) ? $this->config[$key] : $default; } return $this->config; }
Sets the TeamSpeak3_Adapter_Abstract object using this transport.
TeamSpeak3_Adapter_Abstract | $adapter |
Definition at line 187 of file Abstract.php.
{ $this->adapter = $adapter; }
Returns the TeamSpeak3_Adapter_Abstract object using this transport.
Definition at line 197 of file Abstract.php.
Referenced by waitForReadyRead().
{
return $this->adapter;
}
Returns the adapter type.
Definition at line 207 of file Abstract.php.
References TeamSpeak3_Helper_String\factory().
Referenced by TeamSpeak3_Transport_TCP\disconnect(), TeamSpeak3_Transport_UDP\disconnect(), TeamSpeak3_Transport_UDP\read(), TeamSpeak3_Transport_TCP\read(), TeamSpeak3_Transport_TCP\readLine(), TeamSpeak3_Transport_UDP\send(), TeamSpeak3_Transport_TCP\send(), and waitForReadyRead().
{ if($this->adapter instanceof TeamSpeak3_Adapter_Abstract) { $string = TeamSpeak3_Helper_String::factory(get_class($this->adapter)); return $string->substr($string->findLast("_"))->replace(array("_", " "), "")->toString(); } return "Unknown"; }
Returns header/meta data from stream pointer.
TeamSpeak3_Transport_Exception |
Definition at line 225 of file Abstract.php.
{ if($this->stream === null) { throw new TeamSpeak3_Transport_Exception("unable to retrieve header/meta data from stream pointer"); } return stream_get_meta_data($this->stream); }
Returns TRUE if the transport is connected.
Definition at line 240 of file Abstract.php.
Referenced by TeamSpeak3_Adapter_ServerQuery\__destruct(), and waitForReadyRead().
{
return (is_resource($this->stream)) ? TRUE : FALSE;
}
TeamSpeak3_Transport_Abstract::waitForReadyRead | ( | $ | time = 0 | ) | [protected] |
Blocks a stream until data is available for reading if the stream is connected in non-blocking mode.
integer | $time |
Definition at line 252 of file Abstract.php.
References getAdapter(), getAdapterType(), TeamSpeak3_Helper_Signal\getInstance(), and isConnected().
Referenced by TeamSpeak3_Transport_TCP\read(), TeamSpeak3_Transport_UDP\read(), and TeamSpeak3_Transport_TCP\readLine().
{ if(!$this->isConnected() || $this->config["blocking"]) return; do { $read = array($this->stream); $null = null; if($time) { TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "WaitTimeout", $time, $this->getAdapter()); } $time = $time+$this->config["timeout"]; } while(@stream_select($read, $null, $null, $this->config["timeout"]) == 0); }