aboutsummaryrefslogtreecommitdiff
path: root/libdino/src/service/connection_manager.vala
diff options
context:
space:
mode:
Diffstat (limited to 'libdino/src/service/connection_manager.vala')
-rw-r--r--libdino/src/service/connection_manager.vala27
1 files changed, 8 insertions, 19 deletions
diff --git a/libdino/src/service/connection_manager.vala b/libdino/src/service/connection_manager.vala
index 03c97bdb..509964b3 100644
--- a/libdino/src/service/connection_manager.vala
+++ b/libdino/src/service/connection_manager.vala
@@ -178,7 +178,7 @@ public class ConnectionManager {
return;
}
if (network_manager != null && network_manager.State != NetworkManager.CONNECTED_GLOBAL) {
- wait_sec = 60;
+ wait_sec = 30;
}
print(@"recovering in $wait_sec\n");
Timeout.add_seconds(wait_sec, () => {
@@ -194,13 +194,17 @@ public class ConnectionManager {
}
private void check_reconnect(Account account) {
- PingResponseListenerImpl ping_response_listener = new PingResponseListenerImpl(this, account);
+ bool acked = false;
+
Core.XmppStream stream = connections[account].stream;
- stream.get_module(Xep.Ping.Module.IDENTITY).send_ping(stream, account.domainpart, ping_response_listener);
+ stream.get_module(Xep.Ping.Module.IDENTITY).send_ping(stream, account.domainpart, (stream) => {
+ acked = true;
+ change_connection_state(account, ConnectionState.CONNECTED);
+ });
Timeout.add_seconds(5, () => {
if (connections[account].stream != stream) return false;
- if (ping_response_listener.acked) return false;
+ if (acked) return false;
change_connection_state(account, ConnectionState.DISCONNECTED);
try {
@@ -210,21 +214,6 @@ public class ConnectionManager {
});
}
- private class PingResponseListenerImpl : Xep.Ping.ResponseListener, Object {
- public bool acked = false;
- ConnectionManager outer;
- Account account;
- public PingResponseListenerImpl(ConnectionManager outer, Account account) {
- this.outer = outer;
- this.account = account;
- }
- public void on_result(Core.XmppStream stream) {
- print("ping ok\n");
- acked = true;
- outer.change_connection_state(account, ConnectionState.CONNECTED);
- }
- }
-
private void on_nm_state_changed(uint32 state) {
print("nm " + state.to_string() + "\n");
if (state == NetworkManager.CONNECTED_GLOBAL) {