diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-03-10 10:49:51 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2010-03-10 10:49:51 +0000 |
| commit | 617dd2f07a30203fd885a5bad041ada73f9f8db0 (patch) | |
| tree | f2696e06817e7973ce9ef17ba0c02813465e4403 /source | |
| parent | 15fa3fe871c749802d8a9d3322fe7f517e7d7d25 (diff) | |
| download | qxmpp-617dd2f07a30203fd885a5bad041ada73f9f8db0.tar.gz | |
add configuration options for keep alive
Diffstat (limited to 'source')
| -rw-r--r-- | source/QXmppConfiguration.cpp | 36 | ||||
| -rw-r--r-- | source/QXmppConfiguration.h | 11 |
2 files changed, 44 insertions, 3 deletions
diff --git a/source/QXmppConfiguration.cpp b/source/QXmppConfiguration.cpp index 771f305f..059a93ba 100644 --- a/source/QXmppConfiguration.cpp +++ b/source/QXmppConfiguration.cpp @@ -31,7 +31,8 @@ QXmppConfiguration::QXmppConfiguration() : m_port(5222), m_autoAcceptSubscriptions(true), m_sendIntialPresence(true), m_sendRosterRequest(true), - m_keepAlivePingsInterval(100), + m_keepAliveInterval(0), + m_keepAliveTimeout(0), m_autoReconnectionEnabled(true), m_useSASLAuthentication(true), m_ignoreSslErrors(true), @@ -367,6 +368,39 @@ QNetworkProxy QXmppConfiguration::networkProxy() const return m_networkProxy; } +/// Specifies the interval in seconds at which keep alive (ping) packets +/// will be sent to the server. +/// If set to zero, no keep alive packets will be sent. + +void QXmppConfiguration::setKeepAliveInterval(int secs) +{ + m_keepAliveInterval = secs; +} + +/// Returns the keep alive interval in seconds. + +int QXmppConfiguration::keepAliveInterval() const +{ + return m_keepAliveInterval; +} + +/// Specifies the maximum time in seconds to wait for a keep alive response +/// from the server before considering we are disconnected. +/// +/// If set to zero or a value larger than the keep alive interval, +/// no timeout will occur. + +void QXmppConfiguration::setKeepAliveTimeout(int secs) +{ + m_keepAliveTimeout = secs; +} + +/// Returns the keep alive timeout in seconds. + +int QXmppConfiguration::keepAliveTimeout() const +{ + return m_keepAliveTimeout; +} QString QXmppConfiguration::getHost() const { diff --git a/source/QXmppConfiguration.h b/source/QXmppConfiguration.h index ba9e37e2..26eb1ac0 100644 --- a/source/QXmppConfiguration.h +++ b/source/QXmppConfiguration.h @@ -93,6 +93,11 @@ public: QXmppConfiguration::SASLAuthMechanism sASLAuthMechanism() const; QNetworkProxy networkProxy() const; + int keepAliveInterval() const; + void setKeepAliveInterval(int secs); + int keepAliveTimeout() const; + void setKeepAliveTimeout(int secs); + void setHost(const QString&); void setDomain(const QString&); void setPort(int); @@ -146,8 +151,10 @@ private: bool m_sendIntialPresence; // default is true bool m_sendRosterRequest; - // interval in seconds, if negative it won't ping - int m_keepAlivePingsInterval; + // interval in seconds, if zero won't ping + int m_keepAliveInterval; + // interval in seconds, if zero won't timeout + int m_keepAliveTimeout; // will keep reconnecting if disconnected, default is true bool m_autoReconnectionEnabled; bool m_useSASLAuthentication; ///< flag to specify what authentication system |
