mirror of
https://github.com/Karaka-Management/oms-Search.git
synced 2026-02-09 06:48:41 +00:00
41 lines
1.1 KiB
PHP
41 lines
1.1 KiB
PHP
<?php
|
|
declare(strict_types = 1);
|
|
|
|
namespace AdvancedJsonRpc;
|
|
|
|
/**
|
|
* When a rpc call is made, the Server MUST reply with a Response, except for in the case of Notifications. The Response
|
|
* is expressed as a single JSON Object, with the following members:
|
|
*/
|
|
abstract class Response extends Message
|
|
{
|
|
/**
|
|
* This member is REQUIRED. It MUST be the same as the value of the id member in the Request Object. If there was an
|
|
* error in detecting the id in the Request object (e.g. Parse error/Invalid Request), it MUST be Null.
|
|
*
|
|
* @var int|string
|
|
*/
|
|
public $id;
|
|
|
|
/**
|
|
* A message is considered a Response if it has an ID and either a result or an error
|
|
*
|
|
* @param object $msg A decoded message body
|
|
* @return bool
|
|
*/
|
|
public static function isResponse($msg): bool
|
|
{
|
|
return is_object($msg) && property_exists($msg, 'id') && (property_exists($msg, 'result') || isset($msg->error));
|
|
}
|
|
|
|
/**
|
|
* @param int|string $id
|
|
* @param mixed $result
|
|
* @param ResponseError $error
|
|
*/
|
|
public function __construct($id)
|
|
{
|
|
$this->id = $id;
|
|
}
|
|
}
|