Prado\Web\Services\TJsonRpcProtocol::callMethod PHP Метод

callMethod() публичный Метод

Handles the RPC request
public callMethod ( string $requestPayload ) : string
$requestPayload string
Результат string JSON RPC response
    public function callMethod($requestPayload)
    {
        try {
            $_request = $this->decode($requestPayload);
            if (isset($_request['jsonrpc'])) {
                $this->_specificationVersion = $_request['jsonrpc'];
                if ($this->_specificationVersion > 2.0) {
                    throw new TRpcException('Unsupported specification version', '-32600');
                }
            }
            if (isset($_request['id'])) {
                $this->_id = $_request['id'];
            }
            if (!isset($_request['method'])) {
                throw new TRpcException('Missing request method', '-32600');
            }
            if (!isset($_request['params'])) {
                $parameters = array();
            } else {
                $parameters = $_request['params'];
            }
            if (!is_array($parameters)) {
                $parameters = array($parameters);
            }
            // a request without an id is a notification that doesn't need a response
            if ($this->_id !== null) {
                if ($this->_specificationVersion == 2.0) {
                    return $this->encode(array('jsonrpc' => '2.0', 'id' => $this->_id, 'result' => $this->callApiMethod($_request['method'], $parameters)));
                } else {
                    return $this->encode(array('id' => $this->_id, 'result' => $this->callApiMethod($_request['method'], $_request['params']), 'error' => null));
                }
            }
        } catch (TRpcException $e) {
            return $this->createErrorResponse($e);
        } catch (THttpException $e) {
            throw $e;
        } catch (\Exception $e) {
            return $this->createErrorResponse(new TRpcException('An internal error occured', '-32603'));
        }
    }