/** * Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote * server. * * @throws TeamSpeak3_Adapter_Exception * @return void */ public function syn() { $this->initTransport($this->options); $this->transport->setAdapter($this); TeamSpeak3_Helper_Profiler::init(spl_object_hash($this)); TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferConnected", $this); }
/** * Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote * server. * * @throws TeamSpeak3_Adapter_Exception * @return void */ public function syn() { if (!isset($this->options["port"]) || empty($this->options["port"])) { $this->options["port"] = $this->default_port; } $this->initTransport($this->options); $this->transport->setAdapter($this); TeamSpeak3_Helper_Profiler::init(spl_object_hash($this)); TeamSpeak3_Helper_Signal::getInstance()->emit("tsdnsConnected", $this); }
/** * Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote * server. * * @throws TeamSpeak3_Adapter_Exception * @return void */ protected function syn() { $this->initTransport($this->options); $this->transport->setAdapter($this); TeamSpeak3_Helper_Profiler::init(spl_object_hash($this)); if (!$this->getTransport()->readLine()->startsWith(TeamSpeak3::READY)) { throw new TeamSpeak3_Adapter_Exception("invalid reply from the server"); } TeamSpeak3_Helper_Signal::getInstance()->emit("serverqueryConnected", $this); }
/** * Connects the TeamSpeak3_Transport_Abstract object and performs initial actions on the remote * server. * * @throws TeamSpeak3_Adapter_Update_Exception * @return void */ public function syn() { 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(32)); if (!preg_match_all("/,?(\\d+),?/", $this->getTransport()->read(32), $matches) || !isset($matches[1])) { throw new TeamSpeak3_Adapter_Update_Exception("invalid reply from the server"); } $this->build_numbers = $matches[1]; TeamSpeak3_Helper_Signal::getInstance()->emit("updateConnected", $this); }
/** * The TeamSpeak3_Adapter_FileTransfer constructor. * * @param TeamSpeak3_Transport_Abstract $transport * @throws TeamSpeak3_Adapter_Exception * @return TeamSpeak3_Adapter_Abstract */ public function __construct(TeamSpeak3_Transport_Abstract $transport) { $this->transport = $transport; $this->transport->setAdapter($this); TeamSpeak3_Helper_Profiler::init(spl_object_hash($this)); }
/** * Returns the profiler timer used for this connection adapter. * * @return TeamSpeak3_Helper_Profiler_Timer */ public function getProfiler() { return TeamSpeak3_Helper_Profiler::get(spl_object_hash($this)); }
/** * Checks for required PHP features, enables autoloading and starts a default profiler. * * @throws LogicException * @return void */ public static function init() { if (version_compare(phpversion(), "5.2.1") == -1) { throw new LogicException("this particular software cannot be used with the installed version of PHP"); } if (!function_exists("stream_socket_client")) { throw new LogicException("network functions are not available in this PHP installation"); } if (!function_exists("spl_autoload_register")) { throw new LogicException("autoload functions are not available in this PHP installation"); } if (!class_exists("TeamSpeak3_Helper_Profiler")) { spl_autoload_register(array(__CLASS__, "autoload")); } TeamSpeak3_Helper_Profiler::start(); }
/** * Sends a prepared command to the server and returns the result. * * @param string $cmd * @throws TeamSpeak3_Adapter_Exception * @return TeamSpeak3_Adapter_ServerQuery_Reply */ public function request($cmd) { if (strstr($cmd, "\r") || strstr($cmd, "\n")) { throw new TeamSpeak3_Adapter_Exception("illegal characters in command '" . $command . "'"); } if (in_array(TeamSpeak3_Helper_String::factory($cmd)->section(TeamSpeak3::SEPERATOR_CELL), $this->block)) { throw new TeamSpeak3_Adapter_ServerQuery_Exception("command not found", 0x100); } $this->getProfiler()->start(); $this->getTransport()->sendLine($cmd); $this->count++; $str = null; $rpl = array(); do { $str = $this->getTransport()->readLine(); $rpl[] = $str; } while ($str instanceof TeamSpeak3_Helper_String && $str->section(TeamSpeak3::SEPERATOR_CELL) != TeamSpeak3::ERROR); TeamSpeak3_Helper_Profiler::stop(spl_object_hash($this)); return new TeamSpeak3_Adapter_ServerQuery_Reply($rpl, $cmd); }