1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace Innmind\AMQP\Transport\Protocol\v091; |
5
|
|
|
|
6
|
|
|
use Innmind\AMQP\{ |
7
|
|
|
Model\Exchange\Declaration, |
8
|
|
|
Model\Exchange\Deletion, |
9
|
|
|
Transport\Frame, |
10
|
|
|
Transport\Frame\Channel as FrameChannel, |
11
|
|
|
Transport\Frame\Type, |
12
|
|
|
Transport\Frame\Value, |
13
|
|
|
Transport\Frame\Value\UnsignedShortInteger, |
14
|
|
|
Transport\Frame\Value\ShortString, |
15
|
|
|
Transport\Frame\Value\Bits, |
16
|
|
|
Transport\Frame\Value\Table, |
17
|
|
|
Transport\Protocol\Exchange as ExchangeInterface |
18
|
|
|
}; |
19
|
|
|
use Innmind\Math\Algebra\Integer; |
20
|
|
|
use Innmind\Immutable\{ |
21
|
|
|
Str, |
22
|
|
|
Map |
23
|
|
|
}; |
24
|
|
|
|
25
|
|
|
final class Exchange implements ExchangeInterface |
26
|
|
|
{ |
27
|
|
|
public function declare(FrameChannel $channel, Declaration $command): Frame |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
return new Frame( |
30
|
|
|
Type::method(), |
31
|
|
|
$channel, |
32
|
|
|
Methods::get('exchange.declare'), |
33
|
|
|
new UnsignedShortInteger(new Integer(0)), //ticket (reserved) |
34
|
|
|
new ShortString(new Str($command->name())), |
35
|
|
|
new ShortString(new Str((string) $command->type())), |
36
|
|
|
new Bits($command->isPassive()), |
37
|
|
|
new Bits($command->isDurable()), |
38
|
|
|
new Bits($command->isAutoDeleted()), //reserved |
39
|
|
|
new Bits(false), //internal (reserved) |
40
|
|
|
new Bits(!$command->shouldWait()), |
41
|
|
|
new Table(new Map('string', Value::class)) //todo: use $command->arguments() |
|
|
|
|
42
|
|
|
); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
View Code Duplication |
public function delete(FrameChannel $channel, Deletion $command): Frame |
|
|
|
|
46
|
|
|
{ |
47
|
|
|
return new Frame( |
48
|
|
|
Type::method(), |
49
|
|
|
$channel, |
50
|
|
|
Methods::get('exchange.delete'), |
51
|
|
|
new UnsignedShortInteger(new Integer(0)), //ticket (reserved) |
52
|
|
|
new ShortString(new Str($command->name())), |
53
|
|
|
new Bits($command->onlyIfUnused()), |
54
|
|
|
new Bits(!$command->shouldWait()) |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|