Reputation: 495
I have this code. What I`d like to do is to pass a $d variable to publish event, is there a way to do it and how can i publish variable data using Thruway PHP?
$d='123';
$connection->on('open', function (\Thruway\ClientSession $session) use ($connection) {
//publish an event
$session->publish('com.app.deposit', ['Hello, world from PHP!!!'], ['d'=>$d], ["acknowledge" => true])->then(
function () use ($connection) {
$connection->close(); //You must close the connection or this will hang
echo "Publish Acknowledged!\n";
},
function ($error) {
// publish failed
echo "Publish Error {$error}\n";
}
);
});
$connection->open();
Upvotes: 0
Views: 145
Reputation: 495
Oh, got it. Just needed to use
$connection->on('open', function (\Thruway\ClientSession $session) use ($connection,$d) {
Upvotes: 0