示例#1
0
 /**
  * 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);
 }
示例#2
0
 /**
  * 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);
 }
示例#3
0
 /**
  * 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);
 }
示例#4
0
 /**
  * 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);
 }
示例#5
0
 /**
  * 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));
 }
示例#6
0
 /**
  * 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();
 }
示例#8
0
 /**
  * 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);
 }