以下の無名関数を参照してください。0になるfor
まで、次のループ反復に進みたくありません。$Connected
本来あるべき姿で動作しませんでした...これを修正する解決策は何ですか?
$Client = new Client();
for ($i = 1; $i <= 5; $i++) {
$result = $Client->Action(rand(1,1000));
if ($result->isSuccess()) {
$Connected = 1;
}
// Stay in the loop until 'HangupEvent' received
while ($Connected) {
$Client->EventListener(function (EventMessage $event) {
if ($event instanceof HangupEvent) {
// Received Hangup Event - let terminate this while loop ..
$Connected = 0;
}
});
// If $Connected = 0; then go to next `for` loop iteration
}
}