Let the user disable the auto-ping by setting connection_check_interval to 0
This commit is contained in:
parent
4d73c29836
commit
54af1f16a4
2 changed files with 14 additions and 8 deletions
|
@ -115,10 +115,12 @@ section of this documentation.
|
|||
|
||||
**Default value:** ``60``
|
||||
|
||||
A ping is sent to the server every N seconds, N being the value of that option.
|
||||
Change this to a low value if you want to know quickly when you are disconnected,
|
||||
and to a very high value if bandwidth matters so much that you can’t afford
|
||||
100 bytes/minute (seriously?).
|
||||
A ping is sent to the server every N seconds, N being the value of
|
||||
that option. Change this to a low value if you want to know quickly
|
||||
when you are disconnected, and to a very high value if bandwidth
|
||||
matters so much that you can’t afford 100 bytes/minute, or if you
|
||||
don’t want to waste your battery by waking up the TCP connection too
|
||||
often. Disable this ping altogether by setting this value to 0.
|
||||
|
||||
connection_timeout_delay
|
||||
|
||||
|
|
|
@ -115,12 +115,16 @@ class Connection(sleekxmpp.ClientXMPP):
|
|||
Unload and reload the ping plugin, with the new values.
|
||||
"""
|
||||
ping_interval = config.get('connection_check_interval', 60)
|
||||
if ping_interval <= 0:
|
||||
ping_interval = 60
|
||||
timeout_delay = config.get('connection_timeout_delay', 10)
|
||||
if timeout_delay <= 0:
|
||||
timeout_delay = 10
|
||||
# We help the stupid user (with a delay of 0, poezio will try to
|
||||
# reconnect immediately because the timeout is immediately
|
||||
# passed)
|
||||
# 1 second is short, but, well
|
||||
timeout_delay = 1
|
||||
self.plugin['xep_0199'].disable_keepalive()
|
||||
# If the ping_interval is 0 or less, we just disable the keepalive
|
||||
if ping_interval > 0:
|
||||
self.plugin['xep_0199'].enable_keepalive(ping_interval, timeout_delay)
|
||||
|
||||
def start(self):
|
||||
|
|
Loading…
Reference in a new issue