switch (pn_sasl_state($sasl)) { case PN_SASL_CONF: // this state means we need to configure the sasl machinery // tell sasl the mechanisms we support pn_sasl_mechanisms($sasl, "ANONYMOUS"); // tell sasl we're acting as the server pn_sasl_server($sasl); break; case PN_SASL_STEP: // there is authentication data to process, if we supported // anything other than anonymous we might read the data and send // a challenge $mech = pn_sasl_remote_mechanisms($sasl); if ($mech == "ANONYMOUS") { pn_sasl_done($sasl, PN_SASL_OK); pn_connector_set_connection($c, pn_connection()); } else { pn_sasl_done($sasl, PN_SASL_AUTH); } break; case PN_SASL_FAIL: case PN_SASL_IDLE: return; case PN_SASL_PASS: break; } } global $counter; global $sent; global $rcvd; // we are authenticated (all be it anonymously)
$driver = pn_driver(); $c = pn_connector($driver, "0.0.0.0", "5672", $handler); if (!$c) { print "connect failed\n"; return; } // configure for client sasl $sasl = pn_connector_sasl($c); if ($user) { pn_sasl_plain($sasl, $user, $pass); } else { pn_sasl_mechanisms($sasl, "ANONYMOUS"); pn_sasl_client($sasl); } // set up a session with a sender and receiver $conn = pn_connection(); pn_connector_set_connection($c, $conn); pn_connection_set_hostname($conn, "rschloming.servicebus.appfabriclabs.com"); pn_connection_set_container($conn, "asdf"); $ssn = pn_session($conn); $snd = pn_sender($ssn, "sender"); pn_set_target($snd, "queue1"); $rcv = pn_receiver($ssn, "receiver"); pn_set_source($rcv, "queue1"); // open all the endpoints pn_connection_open($conn); pn_session_open($ssn); pn_link_open($snd); pn_link_open($rcv); // set up an initial delivery pn_delivery($snd, "delivery-{$counter}");