3
我想在jaxl中發送消息後執行一些代碼。 哪種回調適合這種情況?jaxl在發送消息回調後
public function test() {
require_once 'JAXL/jaxl.php';
global $client;
$client = new JAXL(array(
'jid' => '[email protected]',
'pass' => 'password',
'log_level' => JAXL_INFO
));
$client->add_cb('on_stream_features', function($stanza) {
global $client,$thisObj;
$client->send_chat_msg('[email protected]','Message');
});
$client->add_cb('on_message_send',function(){ //some thing like this
//some code
});
}
謝謝你的回答。 我想發送一條消息,然後斷開流。 你對這種情況有什麼建議? – superuser
通過調用'$ client-> send_chat_msg();'來簡單地排隊消息,然後通過調用'$ client-> send_end_stream();'立即排隊XMPP流結束數據包(即斷開客戶端)。另外不要忘記爲'on_disconnect'事件註冊回調。一旦你收到回調,你確定你的消息節已經發送。 Jaxl庫確保有序的消息轉發,即消息包在流結束數據包之前已排隊,它將保證它們以相同的順序發送。因此,在您的消息節發送之前,您將不會收到'on_disconnect'回調。 –
謝謝,它的工作原理。 – superuser