[jdev] Is there any way to make sure that there will be a response to presence stanza

david hidalgo david.hidalgo at fon.com
Fri Apr 20 02:48:49 CDT 2007


Sergej Andrejev escribió:
> I'm writing a PHP jabber/xmpp library. So far I can connect and do basic 
> actions, but there is one problem. PHP cannot use unblocking stream when 
> working with SSL. That means when I am sending stanza I must decide 
> whether to wait for a response or not. For example when sending a 
> <message /> I am not waiting for response, but when sending <iq /> I do. 
> Now when sending <presence /> I am not really sure about the response 
> and whether it will arrive or not. So if it arrives everything is fine, 
> but when not my script just hangs there waiting for response. So what I 
> am asking is that is there any type of <presence /> which will 100% 
> return some data (and contacts, if there are some)

Hi, Sergej,
I'm a begginer in jabber app's development, so I'm learning trying anf 
failing...
When I send some xml to the server, I wait for a response in a bucle, 
something like this:
for($i=0; $i<NUM_RETRIES; $i++) {
	$line = $this->receive();
         if (!empty($line)) {
         	return true;
	}
	sleep(SECONDS_TO_RETRY);
}
Obviously, it's not the better way, but I'm learning by the moment.

Regards,
David.



More information about the JDev mailing list