1 | <?php |
||
28 | class Phparia extends PhpariaApi |
||
29 | { |
||
30 | /** |
||
31 | * @var WebSocket |
||
32 | */ |
||
33 | protected $wsClient; |
||
34 | |||
35 | /** |
||
36 | * @var EventLoop\LoopInterface |
||
37 | */ |
||
38 | protected $eventLoop; |
||
39 | |||
40 | /** |
||
41 | * @var LoggerInterface |
||
42 | */ |
||
43 | protected $logger; |
||
44 | |||
45 | /** |
||
46 | * @var AmiClient |
||
47 | */ |
||
48 | protected $amiClient; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | protected $stasisApplicationName; |
||
54 | |||
55 | /** |
||
56 | * @var callable |
||
57 | */ |
||
58 | protected $onStop; |
||
59 | |||
60 | /** |
||
61 | * @param LoggerInterface $logger |
||
62 | */ |
||
63 | 88 | public function __construct(LoggerInterface $logger) |
|
74 | |||
75 | /** |
||
76 | * Connect to ARI and optionally AMI |
||
77 | * |
||
78 | * @param string $ariAddress |
||
79 | * @param string|null $amiAddress |
||
80 | * @param array $streamOptions Example: ['ssl' => ['verify_peer' => false, 'verify_peer_name' => false]]; |
||
81 | * @param array $clientOptions Example: ['verify' => false]; |
||
82 | */ |
||
83 | 88 | public function connect($ariAddress, $amiAddress = null, $streamOptions = [], $clientOptions = []) |
|
96 | |||
97 | /** |
||
98 | * Connect and start the event loop |
||
99 | */ |
||
100 | 40 | public function run() |
|
105 | |||
106 | /** |
||
107 | * Disconnect and stop the event loop |
||
108 | * @return \React\Promise\Promise|\React\Promise\PromiseInterface |
||
109 | */ |
||
110 | public function stop() |
||
126 | |||
127 | /** |
||
128 | * @param callable|callback $callback Must return a promise |
||
129 | */ |
||
130 | public function onStop($callback) |
||
134 | |||
135 | /** |
||
136 | * @param callable|callable $callback |
||
137 | */ |
||
138 | 35 | public function onStasisStart(callable $callback) |
|
142 | |||
143 | /** |
||
144 | * @param callable|callable $callback |
||
145 | */ |
||
146 | public function onStasisEnd(callable $callback) |
||
150 | |||
151 | /** |
||
152 | * @return WebSocket |
||
153 | */ |
||
154 | 1 | public function getWsClient() |
|
158 | |||
159 | /** |
||
160 | * @return EventLoop\LoopInterface |
||
161 | */ |
||
162 | 1 | public function getEventLoop() |
|
166 | |||
167 | /** |
||
168 | * @return LoggerInterface |
||
169 | */ |
||
170 | 1 | public function getLogger() |
|
174 | |||
175 | /** |
||
176 | * @return AmiClient |
||
177 | */ |
||
178 | 1 | public function getAmiClient() |
|
182 | |||
183 | /** |
||
184 | * @return string |
||
185 | */ |
||
186 | public function getStasisApplicationName() |
||
190 | } |