$msg_sent = false;
foreach ($channels as $channel) {
$resolve = function() use ( &$msg_sent )
{
$msg_sent = true;
};
$reject = function( \Exception $e )
{
error_log( $e, 3, './error.txt' . PHP_EOL );
};
$channel->send('hlw')->done( $resolve, $reject );
if ( $msg_sent ){
break;
} else {
continue;
}
}
As you can see above,
$msg_sent is false,
$channels is a array with 3 instance of same objects(have different values)
and when i tap send(), it returns a ExtendedPromiseInterface, in which $resolve is executed when message is sent and $reject when not sent.
So what i want to do is check if the message is sent or not, if not then continue the loop and try to send message to another channel, if sent then break the loop.
But unexpectedly it always return false and the loop runs even if the message is sent.