1 | <?php |
||
16 | class Client implements EventsCapableInterface |
||
17 | { |
||
18 | use EventManagerAwareTrait; |
||
19 | |||
20 | /** |
||
21 | * PAMI client. |
||
22 | * |
||
23 | * @var ClientImpl |
||
24 | */ |
||
25 | protected $connection; |
||
26 | /** |
||
27 | * Custom parameters. |
||
28 | * |
||
29 | * @var array |
||
30 | */ |
||
31 | protected $params = []; |
||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $host; |
||
36 | |||
37 | /** |
||
38 | * Client constructor. |
||
39 | * |
||
40 | * @param string $host |
||
41 | * @param ClientImpl $pami PAMI client |
||
42 | */ |
||
43 | 10 | public function __construct($host, ClientImpl $pami) |
|
48 | |||
49 | /** |
||
50 | * Return the hostname of the connection. |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | 1 | public function getHost() |
|
58 | |||
59 | /** |
||
60 | * Return the PAMI client. |
||
61 | * |
||
62 | * @return ClientImpl |
||
63 | */ |
||
64 | 2 | public function getConnection() |
|
68 | |||
69 | /** |
||
70 | * Return the custom parameters. |
||
71 | * |
||
72 | * @return array |
||
73 | */ |
||
74 | 2 | public function getParams() |
|
78 | |||
79 | /** |
||
80 | * Set the custom parameters. |
||
81 | * |
||
82 | * @param array $params Parameters |
||
83 | * |
||
84 | * @return $this |
||
85 | */ |
||
86 | 2 | public function setParams(array $params) |
|
92 | |||
93 | /** |
||
94 | * Connect to the Asterisk Manager Interface. |
||
95 | * |
||
96 | * @throws \PAMI\Client\Exception\ClientException |
||
97 | * |
||
98 | * @return $this |
||
99 | */ |
||
100 | 2 | public function connect() |
|
113 | |||
114 | /** |
||
115 | * Disconnect from the Asterisk Manager Interface. |
||
116 | * |
||
117 | * @return $this |
||
118 | */ |
||
119 | 2 | public function disconnect() |
|
132 | |||
133 | /** |
||
134 | * Main processing loop. Also called from send(), you should call this in |
||
135 | * your own application in order to continue reading events and responses |
||
136 | * from ami. |
||
137 | * |
||
138 | * @return $this |
||
139 | */ |
||
140 | 2 | public function process() |
|
154 | |||
155 | /** |
||
156 | * Sends a message to AMI. |
||
157 | * |
||
158 | * @param OutgoingMessage $action Action to send |
||
159 | * |
||
160 | * @throws \PAMI\Client\Exception\ClientException |
||
161 | * |
||
162 | * @return \PAMI\Message\Response\ResponseMessage |
||
163 | */ |
||
164 | 2 | public function sendAction(OutgoingMessage $action) |
|
185 | } |
||
186 |