zf8848 / libjingle

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

Logoff by inactivity #128

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm experiencing automatic logoff if I stay a period inactive. Is necessary to 
send periodic presence information to the server (like a ping)? Does libjingle 
do that? Thanks

Original issue reported on code.google.com by diego.cd...@gmail.com on 24 Jan 2011 at 5:46

GoogleCodeExporter commented 9 years ago
u need send ping to activate tcp connection with xmpp server by youslef.

Original comment by greatfoolbear on 25 Jan 2011 at 4:40

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
How to do that? Following the XEP-0199? What would be the time between two 
"ping" stanzas? Should I create a new thread to do the job or put the code in 
somewhere else? Thanks for your answer.

Original comment by diego.cd...@gmail.com on 25 Jan 2011 at 10:55

GoogleCodeExporter commented 9 years ago
sending a ping stanza every 60 seconds in xmpp thread:
<iq from='a@b.com' to='b.com' id='c2s' type='get'><ping xmlns='urn:xmpp:ping' 
/></iq>

Original comment by greatfoolbear on 25 Jan 2011 at 11:04

GoogleCodeExporter commented 9 years ago
Thanks again but it seems that call example doesn't use the xmppthread.cc, it 
uses xmpppump.cc. Should I realy make my changes in the xmppthread.cc? And a 
last doubt: Is the "ping stanza" creation showed bellow correct?

buzz::XmlElement iq(buzz::QN_IQ);
iq.AddAttr(buzz::QN_TYPE,buzz::STR_GET);
iq.AddAttr(buzz::QN_ID,(const char*)talk_base::CreateRandomId());
buzz::QName ping(true,"urn:xmpp:ping","ping");
iq.AddElement(new buzz::XmlElement(ping));

ps 1: I beleive that is not necessary put FROM and TO attributes because Pidgin 
doesn't send them.

ps 2: greatfoolbear, I saw an issue from you concerned about the login example 
but the issue was not finalized. Do you solved your doubts? If yes: Is it 
possible run only the login example? How call example uses it? Only xmpppump.cc?

Original comment by diego.cd...@gmail.com on 25 Jan 2011 at 1:53

GoogleCodeExporter commented 9 years ago
xmpp thread means signaling 
thread(http://code.google.com/apis/talk/libjingle/important_concepts.html), not 
exactly xmppthread.cc. 

I dont kown how to run login example yet.

Original comment by greatfoolbear on 25 Jan 2011 at 2:03

GoogleCodeExporter commented 9 years ago
The login example is used by "call". It's not intended to run alone. 
Regarding with the connection dropping, please refer to the following wiki 
entry: 
http://code.google.com/p/libjingle/wiki/FixTipOfConnectionDrop

Original comment by jun...@google.com on 25 Jan 2011 at 10:46

GoogleCodeExporter commented 9 years ago
how can i test login with some other sample application?

yes, just keep TCP connction alive.

Original comment by greatfoolbear on 26 Jan 2011 at 2:39

GoogleCodeExporter commented 9 years ago
The login example is used by "call"?
who know what it means? I can ran "call.exe" without "login" in right way.

Original comment by greatfoolbear on 26 Jan 2011 at 2:50

GoogleCodeExporter commented 9 years ago
I think that call doesn't use login directly (e.g start the application), it 
just use some classes from login like xmpppump and xmppsocket. You can run 
call.exe if you delete login.exe but if you delete the entire login directory 
you will have a compilation error if you try to recompile the call example.
ps: I'm not sure about the information above. jun...@google.com can confirm
Thanks for all help concerning the connection drop problem

Original comment by diego.cd...@gmail.com on 26 Jan 2011 at 11:33

GoogleCodeExporter commented 9 years ago
if it is true, login.exe(execute file) is useless, why it exists?

Original comment by greatfoolbear on 26 Jan 2011 at 11:57

GoogleCodeExporter commented 9 years ago
I don't know, only jun...@google.com can answer but he changed the status of 
this issue to "done", so I think that he will not reply anymore.

Original comment by diego.cd...@gmail.com on 26 Jan 2011 at 1:13

GoogleCodeExporter commented 9 years ago
First of all, thanks for all help that I got here. I have solved my problem and 
would like to share how I did with everybody with the same problem. You have 
two options: periodically send space (like junliu said in comment #7) or ping 
stanzas following the XEP-0199 format (like greatfoolbear said in comment #4). 
In the first case just follow the link posted by junliu. In the second case you 
have to build the ping stanza. There were two erros in manner that I tried (in 
commment #5): the convert to char* is not possible (I did not payed attention 
in the return value of createRandonID) and you must pass a "true" parameter (to 
use the default namespace) when instantiating the XmlElement that uses the just 
created ping Qname. So the rigth way is:

std::stringstream id;
id << (talk_base::CreateRandomId());
buzz::XmlElement iq(buzz::QN_IQ);
iq.AddAttr(buzz::QN_TYPE,buzz::STR_GET);
iq.AddAttr(buzz::QN_ID,id.str());
buzz::QName ping(true,"urn:xmpp:ping","ping");
iq.AddElement(new buzz::XmlElement(ping, true));

To send the space or the ping stanza periodically I used the PostDelayed method 
from Thread and handled the message in the OnMessage method (inherited from 
MessageHandler) where I call the PostDalayed again to create a periodic loop. I 
don't know if this is the best way. greatfoolbear, could you tell how you 
implemented this functionality?

I hope I've helped.

Original comment by diego.cd...@gmail.com on 27 Jan 2011 at 10:48