我有这个代码。我想要做的是将$ d变量传递给publish事件,有没有办法做到这一点以及如何使用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();
答案 0 :(得分:0)
哦,明白了。只需要使用
$connection->on('open', function (\Thruway\ClientSession $session) use ($connection,$d) {