3namespace PlanetTeamSpeak\TeamSpeak3Framework\Transport;
5use PlanetTeamSpeak\TeamSpeak3Framework\Adapter\Adapter;
6use PlanetTeamSpeak\TeamSpeak3Framework\Exception\TransportException;
7use PlanetTeamSpeak\TeamSpeak3Framework\Helper\Signal;
8use PlanetTeamSpeak\TeamSpeak3Framework\Helper\StringHelper;
55 if (!array_key_exists(
"host",
$config)) {
56 throw new TransportException(
"config must have a key for 'host' which specifies the server host name");
59 if (!array_key_exists(
"port",
$config)) {
60 throw new TransportException(
"config must have a key for 'port' which specifies the server port number");
63 if (!array_key_exists(
"timeout",
$config)) {
67 if (!array_key_exists(
"blocking",
$config)) {
103 if ($this->adapter instanceof
Adapter) {
104 $this->adapter->__destruct();
140 abstract public function send(
string $data): void;
159 public function getConfig(
string $key =
null, mixed $default =
null): array|string|int
162 return array_key_exists($key, $this->config) ? $this->config[$key] : $default;
196 if ($this->adapter instanceof
Adapter) {
197 $string = StringHelper::factory(get_class($this->adapter));
199 return $string->substr($string->findLast(
"\\"))->replace([
"\\",
" "],
"")->toString();
213 if ($this->stream ===
null) {
214 throw new TransportException(
"unable to retrieve header/meta data from stream pointer");
217 return stream_get_meta_data($this->stream);
227 return ($this->
getStream() ===
null) ? false :
true;
239 if (!$this->
isConnected() || $this->config[
"blocking"]) {
248 Signal::getInstance()
252 $time = $time + $this->config[
"timeout"];
253 }
while (@stream_select($read, $null, $null, $this->config[
"timeout"]) == 0);
Enhanced exception class for PlanetTeamSpeak\TeamSpeak3Framework\Transport\Transport objects.
Helper class for string handling.
Abstract class for connecting to a TeamSpeak 3 Server through different ways of transport.
waitForReadyRead(int $time=0)
setAdapter(Adapter $adapter)
__construct(array $config)
getConfig(string $key=null, mixed $default=null)