/** * Constructor. * * @param \Hoa\Socket\Client $client Client. * @param string $script Script. * @return void * @throws \Hoa\Socket\Exception */ public function __construct(Socket\Client $client, $script) { $this->_client = $client; $this->_script = $script; $client->connect(); return; }
/** * Get informations about the shared worker. * * @return array */ public function getInformations() { $this->_client->connect(); $this->_client->writeAll(Backend\Shared::pack(Backend\Shared::TYPE_INFORMATIONS, "")); $this->_client->read(2); // skip type. $length = unpack('Nl', $this->_client->read(4)); $message = $this->_client->read($length['l']); $this->_client->read(1); // skip eom. $this->_client->disconnect(); return unserialize($message); }
/** * Stop the shared worker. * * @return bool */ public function stop() { $client = new Socket\Client($this->_socket); $client->connect(); $client->writeAll(static::pack(static::TYPE_STOP, $this->_password)); $client->disconnect(); return true; }