release 1.3.0

This commit is contained in:
Newcomer1989
2019-06-11 13:04:44 +02:00
parent 311a751f52
commit 46c5f0a6ce
76 changed files with 2580 additions and 4352 deletions

View File

@@ -163,6 +163,27 @@ class TeamSpeak3_Adapter_ServerQuery extends TeamSpeak3_Adapter_Abstract
return new TeamSpeak3_Adapter_ServerQuery_Event($evt, $this->getHost());
}
public function waittsn($lefttime = 0, $delay = 50000)
{
$microbegin = microtime(true);
$token = "\n";
if($this->getTransport()->getConfig("blocking"))
{
throw new TeamSpeak3_Adapter_Exception("only available in non-blocking mode");
}
do {
$evt = $this->getTransport()->readLinetsn($token, $microbegin, $lefttime, $delay);
} while($evt instanceof TeamSpeak3_Helper_String && !$evt->section(TeamSpeak3::SEPARATOR_CELL)->startsWith(TeamSpeak3::EVENT) && (microtime(true) < ($microbegin + $lefttime)));
if($evt instanceof TeamSpeak3_Helper_String && !$evt->section(TeamSpeak3::SEPARATOR_CELL)->startsWith(TeamSpeak3::EVENT)) {
return;
} else {
return new TeamSpeak3_Adapter_ServerQuery_Event($evt, $this->getHost());
}
}
/**
* Uses given parameters and returns a prepared ServerQuery command.

View File

@@ -271,4 +271,31 @@ abstract class TeamSpeak3_Transport_Abstract
}
while(@stream_select($read, $null, $null, $this->config["timeout"]) == 0);
}
protected function waitForReadyReadtsn($time, $microbegin, $lefttime, $delay)
{
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"];
$now = microtime(true);
if($now > ($microbegin + $lefttime)) return;
if(stream_select($read, $null, $null, $this->config["timeout"]) === false) {
throw new TeamSpeak3_Transport_Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
} else {
usleep($delay);
}
}
while($now < ($microbegin + $lefttime));
}
}

View File

@@ -169,6 +169,42 @@ class TeamSpeak3_Transport_TCP extends TeamSpeak3_Transport_Abstract
return $line->trim();
}
public function readLinetsn($token, $microbegin, $lefttime, $delay)
{
$this->connect();
$line = TeamSpeak3_Helper_String::factory("");
while(!$line->endsWith($token))
{
$time = 0;
$this->waitForReadyReadtsn($time, $microbegin, $lefttime, $delay);
$data = @fgets($this->stream, 4096);
TeamSpeak3_Helper_Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);
if($data === FALSE)
{
if($line->count())
{
$line->append($token);
} else {
return;
}
}
else
{
$line->append($data);
}
}
return $line->trim();
}
/**
* Writes data to the stream.