如何在xmpphp中接收消息

时间:2016-04-30 19:27:49

标签: php xmpp chat xmpphp

在示例中清楚地说明了如何发送消息但是,我不清楚如何接收服务器中其他客户端发起的消息,我们非常感谢任何帮助

这是我发送消息的代码

include("xmpphp/xmpp.php");

//username = user without domain, "user" and not "user@server" - home is the resource
$conn = new XMPPHP_XMPP('localhost', 5222, 'robel27', 'yoyene122127', 'kiyos');
// Enables TLS - enabled by default, call before connect()!
$conn->useEncryption(false);

$conn->connect();
 // shows the user's status message
$conn->presence();
$conn->processUntil(array('session_start', 'roster_received'));
$conn->processTime(2);
$conn->message('kiyos12@kiyos', $_POST['msg1']);
$conn->disconnect();

1 个答案:

答案 0 :(得分:0)

要获取消息,您可以使用$data = $conn->processUntil('message');