|
1
|
|
|
<?php |
|
2
|
|
|
namespace Yoanm\JsonRpcServer\Domain\Event\Acknowledge; |
|
3
|
|
|
|
|
4
|
|
|
use Yoanm\JsonRpcServer\Domain\Event\JsonRpcServerEvent; |
|
5
|
|
|
use Yoanm\JsonRpcServer\Domain\Model\JsonRpcCall; |
|
6
|
|
|
use Yoanm\JsonRpcServer\Domain\Model\JsonRpcCallResponse; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class OnResponseSendingEvent |
|
10
|
|
|
* |
|
11
|
|
|
* Dispatched when a response has been successfully serialized by the endpoint and will be returned |
|
12
|
|
|
*/ |
|
13
|
|
|
class OnResponseSendingEvent implements JsonRpcServerEvent |
|
14
|
|
|
{ |
|
15
|
|
|
const EVENT_NAME = 'json_rpc_server_skd.on_response_sending'; |
|
16
|
|
|
|
|
17
|
|
|
/** @var string */ |
|
18
|
|
|
private $responseString; |
|
19
|
|
|
/** @var JsonRpcCallResponse */ |
|
20
|
|
|
private $jsonRpcCallResponse; |
|
21
|
|
|
/** @var null|JsonRpcCall */ |
|
22
|
|
|
private $jsonRpcCall = null; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @param string $responseString |
|
26
|
|
|
* @param JsonRpcCallResponse $jsonRpcCallResponse |
|
27
|
|
|
* @param JsonRpcCall|null $jsonRpcCall |
|
28
|
|
|
*/ |
|
29
|
45 |
|
public function __construct( |
|
30
|
|
|
string $responseString, |
|
31
|
|
|
JsonRpcCallResponse $jsonRpcCallResponse, |
|
32
|
|
|
JsonRpcCall $jsonRpcCall = null |
|
33
|
|
|
) { |
|
34
|
45 |
|
$this->responseString = $responseString; |
|
35
|
45 |
|
$this->jsonRpcCallResponse = $jsonRpcCallResponse; |
|
36
|
45 |
|
$this->jsonRpcCall = $jsonRpcCall; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @return string |
|
41
|
|
|
*/ |
|
42
|
1 |
|
public function getResponseString() : string |
|
43
|
|
|
{ |
|
44
|
1 |
|
return $this->responseString; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @return JsonRpcCallResponse |
|
49
|
|
|
*/ |
|
50
|
1 |
|
public function getJsonRpcCallResponse() : JsonRpcCallResponse |
|
51
|
|
|
{ |
|
52
|
1 |
|
return $this->jsonRpcCallResponse; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @return null|JsonRpcCall |
|
57
|
|
|
*/ |
|
58
|
1 |
|
public function getJsonRpcCall() : ?JsonRpcCall |
|
59
|
|
|
{ |
|
60
|
1 |
|
return $this->jsonRpcCall; |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|