aboutsummaryrefslogtreecommitdiffstats
path: root/AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOConnection.java
diff options
context:
space:
mode:
Diffstat (limited to 'AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOConnection.java')
-rw-r--r--AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOConnection.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOConnection.java b/AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOConnection.java
index 9b03541..c8381cb 100644
--- a/AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOConnection.java
+++ b/AndroidAsync/src/com/koushikdutta/async/http/socketio/SocketIOConnection.java
@@ -30,6 +30,7 @@ import java.util.Hashtable;
class SocketIOConnection {
AsyncHttpClient httpClient;
int heartbeat;
+ long reconnectDelay;
ArrayList<SocketIOClient> clients = new ArrayList<SocketIOClient>();
SocketIOTransport transport;
SocketIORequest request;
@@ -37,6 +38,7 @@ class SocketIOConnection {
public SocketIOConnection(AsyncHttpClient httpClient, SocketIORequest request) {
this.httpClient = httpClient;
this.request = request;
+ this.reconnectDelay = this.request.config.reconnectDelay;
}
public boolean isConnected() {
@@ -157,7 +159,7 @@ class SocketIOConnection {
return;
}
- reconnectDelay = 1000L;
+ reconnectDelay = request.config.reconnectDelay;
SocketIOConnection.this.transport = result;
attach();
}
@@ -216,10 +218,13 @@ class SocketIOConnection {
reconnect(null);
}
}, reconnectDelay);
- reconnectDelay *= 2;
+
+ reconnectDelay = reconnectDelay * 2;
+ if (request.config.reconnectDelayMax > 0L) {
+ reconnectDelay = Math.min(reconnectDelay, request.config.reconnectDelayMax);
+ }
}
- long reconnectDelay = 1000L;
private void reportDisconnect(final Exception ex) {
if (ex != null) {
request.loge("socket.io disconnected", ex);