fabiang / xmpp

Library for XMPP protocol connections (Jabber) for PHP
Other
179 stars 83 forks source link

Receive message #84

Closed andriusvo closed 5 years ago

andriusvo commented 5 years ago

Hey guys,

I already seen a lot of topics about receiving messages but no one helped for me and I can't understand how to receive message.

For testing purposes I'm using 616.pub server to send messages to user. F.e. I authenticated as User1 (using this library). Next step is I'm waiting for User2 (from 616.pub server) to send me a message. When User2 sent a message I want to receive it, but

$input = $client->getConnection()->receive(); is not working.

May be I'm doing something wrong?

$client = new Client($options); $client->connect(); $input = $client->getConnection()->receive();

youmad commented 5 years ago

@SSMellow, have you tried this?

andriusvo commented 5 years ago

@youmad yeah, It works, but then I Iterate through DomDocument to get all DomElements, I only get one DOMElement which contains tagName stream:stream without any value (message)

youmad commented 5 years ago

Well, @SSMellow, I think you should implement your own event listener and catch events like message, body and subject. Maybe you will have to fork this repo and modify some parts to be able to raise these events. Anyway, you can try do debug events, raises during \Fabiang\Xmpp\Stream\XMLStream::parse(), I think it can help you.

youmad commented 5 years ago

but then I Iterate through DomDocument to get all DomElements, I only get one DOMElement which contains tagName stream:stream without any value (message)

Try to dump the whole variable and look onto it instead.