romi4rd1 / xmpphp

Automatically exported from code.google.com/p/xmpphp
0 stars 0 forks source link

Get Roster handle patch #31

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Attached is a patch to handle the get roster so you can return it as an
array keyed by the jid with subscription, groups and name.
Might actually have to add a little more for the array merge incase there
is more than one group but this is a good start for it. Also added the
event so process until can detect when it is finished. Patch is attached. 

Original issue reported on code.google.com by darren...@gmail.com on 30 Aug 2008 at 7:47

Attachments:

GoogleCodeExporter commented 8 years ago
Re did the patch with the payload now being handled so the event will also 
return the
payload when using the processUntil command.
Added the necessary support for more than one group per jid so it will be 
handled by
the system.
Please disregard the getroster.patch above since this new patch updates and 
improves it.

Original comment by darren...@gmail.com on 2 Sep 2008 at 6:15

Attachments:

GoogleCodeExporter commented 8 years ago
I have a question: What is $xml ? A void variable ? Or a variable from an other
function ?
Sorry for my english but I'm French :)

Original comment by Jonama...@gmail.com on 27 Oct 2008 at 2:00

GoogleCodeExporter commented 8 years ago
XMP is an object that is built when a packet arrives in the xmpphp library. It 
is
passed into this function when it is called by the handler that was provided 
the id
of the packet sent out in the roster function above.

Original comment by darren...@gmail.com on 27 Oct 2008 at 2:03

GoogleCodeExporter commented 8 years ago
Ok, thank's.
But, I would know what it a method for recupere the roster ?
And, if use your patch, I have a fatal error, the function sub() doesn't exists.

Original comment by Jonama...@gmail.com on 27 Oct 2008 at 2:19

GoogleCodeExporter commented 8 years ago
Patch was against a revision 54 so it might have changed, hence not sure why 
your
getting a fatal error, it is working in the drupal environment and is part of a
module there that community members have no problems with. 

Regarding the method for getting the roster,    
public function getRoster() {
        $id = $this->getID();
        $this->addIdHandler($id, 'roster_get_handler');
        $this->send("<iq xmlns='jabber:client' type='get' id='$id'><query
xmlns='jabber:iq:roster' /></iq>");
    }
This is the function used to get the roster, and the addIdHandler lets us know 
that
it should call roster_get_handler when it receive the response to the IQ packet.

Original comment by darren...@gmail.com on 27 Oct 2008 at 2:44

GoogleCodeExporter commented 8 years ago
The Fatal error is mine, because an error of coding.
But I don't understand, the function getRoster() call roster_get_handler() but 
this
function return nothing.
And, I would see a log, the class call log(), but it's a mathematic function !

Original comment by Jonama...@gmail.com on 27 Oct 2008 at 3:05

GoogleCodeExporter commented 8 years ago
Roster objects now in SVN

Original comment by nathanfr...@gmail.com on 26 Nov 2008 at 9:50

GoogleCodeExporter commented 8 years ago
help! Who can help me get in the XMPP roster? thanks!

My code:
<?php
$conn = new XMPPHP_XMPP(.....);
try {
     $conn->connect();
     $conn->processUntil('session_start');
     $conn->presence();
     $a = $conn->getRoster();
     print_r($a);
     $b = $conn->roster->getRoster();
     //$conn->disconnect();
} catch(XMPPHP_Exception $e) {
    return;
} catch (Exception $e) {
    echo $e->getMessage();
}

the Result is null...

Original comment by illuspas@gmail.com on 4 Feb 2012 at 4:11

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Function for  XMPP roster + online friends information.

$user_name = 'XXXXXXXXXXX'
$password = 'xxxxxxxxxxx';
$end_loop = 0;
$conn = new XMPPHP_XMPP('talk.google.com', 5222, $user_name,$password, 
"xmpphp", 'gmail.com', $printlog=false, $loglevel=XMPPHP_Log::LEVEL_INFO);
$conn->autoSubscribe(); 
try {
    $conn->connect();   
    while($end_loop <=0) {
        $payloads = $conn->processUntil(array('end_stream', 'session_start','roster_received'));
        foreach($payloads as $event) {
            $pl = $event[1];
            switch($event[0]) {
                case 'session_start':
                    $conn->getRoster();
                    $conn->presence('I m presence'.time());
                    break;

                    case 'roster_received':
                    $array_contact=$pl;

                    foreach($array_contact as $user => $friends_name){
            echo "<li>".$user.'_NAME_'.$friends_name['name'].'</li>';
                    }
                    $end_loop++;
                    break;
                }
            }       
        }

        while(1)
        {
            $payloads = $conn->processUntil(array('presence'));
            echo "<li>".$payloads[0][1]['from']."_Show_". $payloads[0][1]['show']."</li>";

        }

    $conn->disconnect();
    } catch(XMPPHP_Exception $e) {
        die($e->getMessage());
    }

Original comment by jay.vinf...@gmail.com on 16 Jul 2012 at 11:29

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi All,

I'm trying  to get available users list using 

while(1)
        {
            $payloads = $conn->processUntil(array('presence'));
            echo "<li>".$payloads[0][1]['from']."_Show_". $payloads[0][1]['show']."</li>";

        }

But i'm not getting any result. But i can able to send message. Also, to 
receive a message from other end there is a infinite loop running to get 
available users and message, so, my browser getting crashed frequently. I'm 
running this from my local machine. Kindly help me out.

Also i tried to get roster list, but its not working($conn->getRoster();). 

Do we need infinite loop at every time or we have any other option?

Your reply may useful to me, to fix my problems.

Note: I'm running scripts from my local machine using WAMP server.

Original comment by gokul.ga...@gmail.com on 3 Jun 2013 at 10:55