@@ -31,13 +31,14 @@ Once [installed](#install), you can use the following code to access your local
3131Asterisk Telephony instance and issue some simple commands via AMI:
3232
3333``` php
34+ $loop = React\EventLoop\Factory::create();
3435$factory = new Factory($loop);
3536
3637$factory->createClient('user:secret@localhost')->then(function (Client $client) {
3738 echo 'Client connected' . PHP_EOL;
3839
39- $api = new Api ($client);
40- $api ->listCommands()->then(function (Response $response) {
40+ $sender = new ActionSender ($client);
41+ $sender ->listCommands()->then(function (Response $response) {
4142 echo 'Available commands:' . PHP_EOL;
4243 var_dump($response);
4344 });
@@ -103,7 +104,7 @@ The `close()` method can be used to force-close the AMI connection and reject al
103104The ` end() ` method can be used to soft-close the AMI connection once all pending actions are completed.
104105
105106> Advanced: Creating [ ` Action ` ] ( #action ) objects, sending them via AMI and waiting for incoming
106- > [ ` Response ` ] ( #response ) objects is usually hidden behind the [ ` Api ` ] ( #api ) interface.
107+ > [ ` Response ` ] ( #response ) objects is usually hidden behind the [ ` ActionSender ` ] ( #actionsender ) interface.
107108>
108109> If you happen to need a custom or otherwise unsupported action, you can also do so manually
109110> as follows. Consider filing a PR though :)
@@ -114,29 +115,29 @@ The `end()` method can be used to soft-close the AMI connection once all pending
114115> The ` request(Action $action) ` method can be used to queue the given messages to be sent via AMI
115116> and wait for a [ ` Response ` ] ( #response ) object that matches the value of its "ActionID" field.
116117
117- ### Api
118+ ### ActionSender
118119
119- The ` Api ` wraps a given [ ` Client ` ] ( #client ) instance to provide a simple way to execute common actions.
120+ The ` ActionSender ` wraps a given [ ` Client ` ] ( #client ) instance to provide a simple way to execute common actions.
120121This class represents the main interface to execute actions and wait for the corresponding responses.
121122
122123``` php
123- $api = new Api ($client);
124+ $sender = new ActionSender ($client);
124125
125- $api ->ping()->then(function (Response $response) {
126+ $sender ->ping()->then(function (Response $response) {
126127 // response received for ping action
127128});
128129```
129130
130131All public methods resemble their respective AMI actions.
131- Listing all available actions is out of scope here, please refer to the [ class outline] ( src/Api .php ) .
132+ Listing all available actions is out of scope here, please refer to the [ class outline] ( src/ActionSender .php ) .
132133
133134Sending actions is async (non-blocking), so you can actually send multiple action requests in parallel.
134135The AMI will respond to each action with a [ ` Response ` ] ( #response ) object. The order is not guaranteed.
135136Sending actions uses a Promise-based interface that makes it easy to react to when an action is * fulfilled*
136137(i.e. either successfully resolved or rejected with an error):
137138
138139``` php
139- $api ->ping()->then(
140+ $sender ->ping()->then(
140141 function (Response $response) {
141142 // response received for ping action
142143 },
@@ -153,11 +154,11 @@ $api->ping()->then(
153154});
154155```
155156
156- > Advanced: Using the ` Api ` is not strictly necessary, but is the recommended way to execute common actions.
157+ > Advanced: Using the ` ActionSender ` is not strictly necessary, but is the recommended way to execute common actions.
157158>
158159> If you happen to need a new or otherwise unsupported action, or additional arguments,
159160> you can also do so manually. See the advanced [ ` Client ` ] ( #client ) usage above for details.
160- > A PR that updates the ` Api ` is very much appreciated :)
161+ > A PR that updates the ` ActionSender ` is very much appreciated :)
161162
162163### Message
163164
0 commit comments