@@ -61,6 +61,8 @@ $loop = \React\EventLoop\Factory::create();
6161$factory = new Factory($loop);
6262```
6363
64+ #### createClient()
65+
6466The ` createClient($amiUrl) ` method can be used to create a new ` Client ` .
6567It helps with establishing a plain TCP/IP or secure SSL connection to the AMI
6668and issuing an initial ` login ` action.
@@ -84,6 +86,8 @@ $factory->createClient('user:secret@localhost')->then(
8486The ` Client ` is responsible for exchanging messages with the Asterisk Manager Interface
8587and keeps track of pending actions.
8688
89+ #### on()
90+
8791The ` on($eventName, $eventHandler) ` method can be used to register a new event handler.
8892Incoming events and errors will be forwarded to registered event handler callbacks:
8993
@@ -99,21 +103,31 @@ $client->on('error', function (Exception $e) {
99103});
100104```
101105
106+ #### close()
107+
102108The ` close() ` method can be used to force-close the AMI connection and reject all pending actions.
103109
110+ #### end()
111+
104112The ` end() ` method can be used to soft-close the AMI connection once all pending actions are completed.
105113
106- > Advanced: Creating [ ` Action ` ] ( #action ) objects, sending them via AMI and waiting for incoming
107- > [ ` Response ` ] ( #response ) objects is usually hidden behind the [ ` ActionSender ` ] ( #actionsender ) interface.
108- >
109- > If you happen to need a custom or otherwise unsupported action, you can also do so manually
110- > as follows. Consider filing a PR though :)
111- >
112- > The ` createAction($name, $fields) ` method can be used to construct a custom AMI action.
113- > A unique value will be added to "ActionID" field automatically (needed to match incoming responses).
114- >
115- > The ` request(Action $action) ` method can be used to queue the given messages to be sent via AMI
116- > and wait for a [ ` Response ` ] ( #response ) object that matches the value of its "ActionID" field.
114+ #### Advanced
115+
116+ Creating [ ` Action ` ] ( #action ) objects, sending them via AMI and waiting for incoming
117+ [ ` Response ` ] ( #response ) objects is usually hidden behind the [ ` ActionSender ` ] ( #actionsender ) interface.
118+
119+ If you happen to need a custom or otherwise unsupported action, you can also do so manually
120+ as follows. Consider filing a PR though :)
121+
122+ ##### createAction()
123+
124+ The ` createAction($name, $fields) ` method can be used to construct a custom AMI action.
125+ A unique value will be added to "ActionID" field automatically (needed to match incoming responses).
126+
127+ ##### request()
128+
129+ The ` request(Action $action) ` method can be used to queue the given messages to be sent via AMI
130+ and wait for a [ ` Response ` ] ( #response ) object that matches the value of its "ActionID" field.
117131
118132### ActionSender
119133
@@ -122,15 +136,22 @@ This class represents the main interface to execute actions and wait for the cor
122136
123137``` php
124138$sender = new ActionSender($client);
139+ ```
140+
141+ #### Actions
125142
143+ All public methods resemble their respective AMI actions.
144+
145+ ``` php
126146$sender->ping()->then(function (Response $response) {
127147 // response received for ping action
128148});
129149```
130150
131- All public methods resemble their respective AMI actions.
132151Listing all available actions is out of scope here, please refer to the [ class outline] ( src/ActionSender.php ) .
133152
153+ #### Processing
154+
134155Sending actions is async (non-blocking), so you can actually send multiple action requests in parallel.
135156The AMI will respond to each action with a [ ` Response ` ] ( #response ) object. The order is not guaranteed.
136157Sending actions uses a Promise-based interface that makes it easy to react to when an action is * fulfilled*
@@ -154,11 +175,13 @@ $sender->ping()->then(
154175});
155176```
156177
157- > Advanced: Using the ` ActionSender ` is not strictly necessary, but is the recommended way to execute common actions.
158- >
159- > If you happen to need a new or otherwise unsupported action, or additional arguments,
160- > you can also do so manually. See the advanced [ ` Client ` ] ( #client ) usage above for details.
161- > A PR that updates the ` ActionSender ` is very much appreciated :)
178+ #### Custom actions
179+
180+ Using the ` ActionSender ` is not strictly necessary, but is the recommended way to execute common actions.
181+
182+ If you happen to need a new or otherwise unsupported action, or additional arguments,
183+ you can also do so manually. See the advanced [ ` Client ` ] ( #client ) usage above for details.
184+ A PR that updates the ` ActionSender ` is very much appreciated :)
162185
163186### Message
164187
@@ -168,14 +191,22 @@ It provides a common interface for these three message types.
168191Each ` Message ` consists of any number of fields with each having a name and one or multiple values.
169192Field names are matched case-insensitive. The interpretation of values is application specific.
170193
194+ #### getFieldValue()
195+
171196The ` getFieldValue($key) ` method can be used to get the first value for the given field key.
172197If no value was found, ` null ` is returned.
173198
199+ #### getFieldValues()
200+
174201The ` getFieldValues($key) ` method can be used to get a list of all values for the given field key.
175202If no value was found, an empty ` array() ` is returned.
176203
204+ #### getFields()
205+
177206The ` getFields() ` method can be used to get an array of all fields.
178207
208+ #### getActionId()
209+
179210The ` getActionId() ` method can be used to get the unique action ID of this message.
180211This is a shortcut to get the value of the "ActionID" field.
181212
@@ -184,6 +215,8 @@ This is a shortcut to get the value of the "ActionID" field.
184215The ` Response ` value object represents the incoming response received from the AMI.
185216It shares all properties of the [ ` Message ` ] ( #message ) parent class.
186217
218+ ##### getCommandOutput()
219+
187220The ` getCommandOutput() ` method can be used to get the resulting output of
188221a "command" [ ` Action ` ] ( #action ) .
189222This value is only available if this is actually a response to a "command" action,
@@ -205,6 +238,8 @@ It shares all properties of the [`Message`](#message) parent class.
205238The ` Event ` value object represents the incoming event received from the AMI.
206239It shares all properties of the [ ` Message ` ] ( #message ) parent class.
207240
241+ ##### getName()
242+
208243The ` getName() ` method can be used to get the name of the event.
209244This is a shortcut to get the value of the "Event" field.
210245
0 commit comments