private function process($json) { if (!($struct = Rpc::decode($json, $batch))) { $code = is_null($struct) ? Rpc::ERR_PARSE : Rpc::ERR_REQUEST; $data = new Response(); $data->createStdError($code); return $data->toJson(); } $this->getRequests($struct); $this->processRequests(); $data = implode(',', $this->responses); return $batch && $data ? '[' . $data . ']' : $data; }
private function checkResult() { $sent = count($this->requests); $expected = $sent - $this->notifications; if (!($struct = Rpc::decode($this->output, $batch))) { if ($expected) { $this->setError('Parse error'); } return !$expected; } if ($res = $this->checkResponses($struct, $batch)) { if (!$this->checkReceived($struct, $batch, $expected)) { return; } if ($this->multi) { $this->batch = $struct; } else { if (isset($struct->error)) { $this->setError($struct->error); $res = false; } else { $this->result = $struct->result; } } } return $res; }