Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent reattaching of detached channels #977

Merged
merged 1 commit into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public void transferToChannels(List<ConnectionManager.QueuedMessage> queuedMessa

for (Map.Entry<String, Channel> 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)){
Expand Down
2 changes: 1 addition & 1 deletion lib/src/main/java/io/ably/lib/realtime/ChannelBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()){
ttypic marked this conversation as resolved.
Show resolved Hide resolved
attach(true,null);
} else if (state == ChannelState.suspended) {
/* (RTL3d) If the connection state enters the CONNECTED state, then
Expand Down
4 changes: 4 additions & 0 deletions lib/src/main/java/io/ably/lib/realtime/ChannelState.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Loading