diff --git a/lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java b/lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java index ffb33d426..c46e21a38 100644 --- a/lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java +++ b/lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java @@ -256,7 +256,7 @@ public void transferToChannels(List queuedMessa for (Map.Entry channelEntry : map.entrySet()) { Channel channel = channelEntry.getValue(); - if (channel.state == ChannelState.attaching || channel.state == ChannelState.attached || channel.state == ChannelState.suspended) { + if (channel.state.isReattachable()) { Log.d(TAG, "reAttach(); channel = " + channel.name); if (channelQueueMap.containsKey(channel.name)){ diff --git a/lib/src/main/java/io/ably/lib/realtime/ChannelBase.java b/lib/src/main/java/io/ably/lib/realtime/ChannelBase.java index 1da00e9ba..861db6c2d 100644 --- a/lib/src/main/java/io/ably/lib/realtime/ChannelBase.java +++ b/lib/src/main/java/io/ably/lib/realtime/ChannelBase.java @@ -586,7 +586,7 @@ public void run() { /* State changes provoked by ConnectionManager state changes. */ public void setConnected(boolean reattachOnResumeFailure) { - if (reattachOnResumeFailure){ + if (reattachOnResumeFailure && state.isReattachable()){ attach(true,null); } else if (state == ChannelState.suspended) { /* (RTL3d) If the connection state enters the CONNECTED state, then diff --git a/lib/src/main/java/io/ably/lib/realtime/ChannelState.java b/lib/src/main/java/io/ably/lib/realtime/ChannelState.java index 5033007c4..bb7b7b58c 100644 --- a/lib/src/main/java/io/ably/lib/realtime/ChannelState.java +++ b/lib/src/main/java/io/ably/lib/realtime/ChannelState.java @@ -47,4 +47,8 @@ public enum ChannelState { public ChannelEvent getChannelEvent() { return event; } + + public boolean isReattachable() { + return this == ChannelState.attaching || this == ChannelState.attached || this == ChannelState.suspended; + } }