[Delta] trying to make a code like justins code (jabber example) but i have errors
Justin Karneges
justin-psi2 at affinix.com
Mon Mar 24 16:49:57 PDT 2008
On Monday 24 March 2008 4:09 pm, K. Nimer wrote:
> i guess it does say "press any key to continue" which tells me that yes it
> does quit
> so what do u mean by making it loop?
Iris is event-based and uses the Qt event loop to operate. You should
probably learn some more about Qt programming in general if you don't
understand this...
Basically, when you call sendMessage(), this queues your request to send the
message. The message will be sent "in the background". If you quit
instantly after queuing the request then Iris will not have a chance to send
the message.
Instead of abruptly quitting the application after requesting to send the
message, try cleanly logging out from the server. This will ensure Iris has
transmitted all of the data needed. To do this, you call client->close().
When the logout process has completed, then the delayedCloseFinished() signal
is emitted. Only then should the application quit.
Add a new slot:
void stream_delayedCloseFinished()
{
// at this point we are disconnected from the server. we can quit safely.
QCoreApplication::instance()->quit();
}
And of course listen for it, just like the other signals:
connect( m_pStream, SIGNAL( delayedCloseFinished() ), SLOT(
stream_delayedCloseFinished() ) );
Now, instead of calling QCoreApplication::instance()->quit() elsewhere in your
program, call m_pClient->close().
For example:
void stream_authenticated()
{
m_pClient->start( m_jid.host(), m_jid.user(), m_pass, m_jid.resource() );
std::cout << "Authenticated on server - sweet!" << std::endl;
// our work here is done...
m_pClient->close();
}
-Justin
More information about the Delta
mailing list