@@ -21,20 +21,20 @@ public function __construct(Client $client)
2121
2222 public function coreShowChannels ()
2323 {
24- return $ this ->collectEvents ('CoreShowChannels ' );
24+ return $ this ->collectEvents ('CoreShowChannels ' , ' CoreShowChannelsComplete ' );
2525 }
2626
2727 public function sipPeers ()
2828 {
29- return $ this ->collectEvents ('SIPPeers ' );
29+ return $ this ->collectEvents ('SIPPeers ' , ' PeerlistComplete ' );
3030 }
3131
3232 public function agents ()
3333 {
34- return $ this ->collectEvents ('Agents ' );
34+ return $ this ->collectEvents ('Agents ' , ' AgentsComplete ' );
3535 }
3636
37- private function collectEvents ($ command )
37+ private function collectEvents ($ command, $ expectedEndEvent )
3838 {
3939 $ req = new Action ($ command );
4040 $ ret = $ this ->client ->request ($ req );
@@ -44,11 +44,11 @@ private function collectEvents($command)
4444
4545 // collect all intermediary channel events with this action ID
4646 $ collected = array ();
47- $ collector = function (Event $ event ) use ($ id , &$ collected , $ deferred ) {
47+ $ collector = function (Event $ event ) use ($ id , &$ collected , $ deferred, $ expectedEndEvent ) {
4848 if ($ event ->getActionId () === $ id ) {
4949 $ collected []= $ event ;
5050
51- if ($ event ->getPart ( ' EventList ' ) === ' Complete ' ) {
51+ if ($ event ->getName ( ) === $ expectedEndEvent ) {
5252 $ deferred ->resolve ($ collected );
5353 }
5454 }
0 commit comments