1

I have an app where I send xmpp message to some devices. This successfully works. But now I want to recieve roster (list of connected users) and I get empty array, however there are 4 users there. Here is my code

   require_once($_SERVER["DOCUMENT_ROOT"]."/lib/xmpphp/XMPP.php");
    $con=$conf->getXMPPObj();
    try {
            $con->useEncryption(false);
            $con->connect();
            $con->processUntil('session_start');
            $con->presence();
            $roster=$con->roster->getRoster();
            var_dump($roster);
            //$con->processUntil('roster_received');
            if (strpos($_POST['msg'],'CamMode')!==false)
            {
                $con->message("user@host" ,$_POST['msg']);
            }
            else
            {
                $con->message("user@host",$_POST['msg']);
            }     
            $con->disconnect();
        } 
        catch(XMPPHP_Exception $e) 
        {
            die($e->getMessage());
        }

messages are successfully sent but dump of $roster is empty. What's wrong?

Sergey Scopin
  • 2,217
  • 9
  • 39
  • 67

1 Answers1

0

I add this : $con->processUntil(array('session_start', 'roster_received')); and $con->processTime(5); It worked for me.

        ...
        $con->connect();
        $payloads = $con->processUntil(array('session_start', 'roster_received'));
        $con->presence();
        $con->processTime(5);
        $roster = $con->roster->getRoster();
        ...