if ($msg) { print "message: {$tag}\n"; } if ($cd < 0) { if ($cd == PN_EOS) { // now that we hit the end of the message, updated the // disposition and advance the link to the next message pn_disposition($delivery, PN_ACCEPTED); pn_advance($lnk); break; } else { print "error reading message: {$cd}\n"; } } } if (pn_credit($lnk) < 10) { pn_flow($lnk, 10); } } else { if (pn_writable($delivery)) { // we have capacity to write, so let's send a message list($cd, $msg) = pn_message_data("this is message {$tag}", 1024); $n = pn_send($lnk, $msg); if ($n != strlen($msg)) { print "error sending message: {$cd}"; } if (pn_advance($lnk)) { print "sent {$tag}\n"; pn_delivery($lnk, "delivery-{$counter}"); $counter++; }
} if ($cd < 0) { if ($cd == PN_EOS) { // now that we hit the end of the message, updated the // disposition and advance the link to the next message pn_disposition($delivery, PN_ACCEPTED); pn_advance($lnk); $rcvd++; break; } else { print "error reading message: {$cd}\n"; } } } $delta = min($count ? $count : 10 - $rcvd, 10); if ($delta && pn_credit($lnk) < $delta) { pn_flow($lnk, $delta); } if ($count && $rcvd == $count) { pn_link_close($lnk); } } else { if (pn_writable($delivery)) { // we have capacity to write, so let's send a message list($cd, $msg) = pn_message_data("this is message {$tag}", 1024); $n = pn_send($lnk, $msg); if ($n != strlen($msg)) { print "error sending message: {$cd}"; } if (pn_advance($lnk)) { print "sent {$tag}\n";