-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathAckResolver.php
44 lines (34 loc) · 1.01 KB
/
AckResolver.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace React\Stomp;
use React\Stomp\Client;
class AckResolver
{
private $result;
private $client;
private $subscriptionId;
private $messageId;
public function __construct(Client $client, $subscriptionId, $messageId)
{
$this->client = $client;
$this->subscriptionId = $subscriptionId;
$this->messageId = $messageId;
}
public function ack(array $headers = array())
{
$this->throwExceptionIfResolved();
$this->result = true;
$this->client->ack($this->subscriptionId, $this->messageId, $headers);
}
public function nack(array $headers = array())
{
$this->throwExceptionIfResolved();
$this->result = false;
$this->client->nack($this->subscriptionId, $this->messageId, $headers);
}
private function throwExceptionIfResolved()
{
if (null !== $this->result) {
throw new \RuntimeException('You must not try to resolve an acknowledgement more than once.');
}
}
}