/** * @param string $command * @param array $data * * @return mixed * * @throws BlockSizeSocketException * @throws ClientNotInitializedException * @throws NullSocketResponseException * @throws SignatureSocketException * @throws SocketException * @throws SocketReadException */ protected function callService($command, $data = array()) { if (!$this->init) { throw new ClientNotInitializedException(); } $data['auth.key'] = $this->clientApiConfig->getKey(); $data['auth.secret'] = $this->clientApiConfig->getSecret(); $data['command'] = $command; $data['project_id'] = $this->clientApiConfig->getProjectId(); $msg = json_encode($data) . PHP_EOL; $this->sendMessage($msg); $buffer = $this->readSocket(); if ($this->debug) { print $buffer; } $result = json_decode($buffer, true); if (!count($result)) { throw new NullSocketResponseException(); } return $result; }