Skip to content

Commit

Permalink
Refactored attach channels with right spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Dec 8, 2023
1 parent da67abc commit 68a9f0a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/src/main/java/io/ably/lib/realtime/AblyRealtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ private void clear() {
}
}

// RTN19b
protected void reattachChannels() {
for (Channel channel : this.channels.values()) {
if (channel.state == ChannelState.attaching || channel.state == ChannelState.attached || channel.state == ChannelState.suspended) {
Log.d(TAG, "reAttach(); channel = " + channel.name);
channel.attach(true, null);
}
}
}

protected void setChannelSerialsFromRecoverOption(Map<String, String> serials) {
for (Map.Entry<String, String> entry : serials.entrySet()) {
String channelName = entry.getKey();
Expand All @@ -295,15 +305,6 @@ protected void setChannelSerialsFromRecoverOption(Map<String, String> serials) {
}
}

protected void reattachChannels() {
for (Channel channel : this.channels.values()) {
if (channel.state == ChannelState.attaching || channel.state == ChannelState.attached || channel.state == ChannelState.suspended) {
Log.d(TAG, "reAttach(); channel = " + channel.name);
channel.attach(true, null);
}
}
}

protected Map<String, String> getChannelSerials() {
Map<String, String> channelSerials = new HashMap<>();
for (Channel channel : this.channels.values()) {
Expand Down
3 changes: 3 additions & 0 deletions lib/src/main/java/io/ably/lib/realtime/Connection.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public void close() {
public void onConnectionStateChange(ConnectionStateChange stateChange) {
state = stateChange.current;
reason = stateChange.reason;
if (state == ConnectionState.connected) { // RTN19b
ably.reattachChannels();
}
emit(state, stateChange);
}

Expand Down

0 comments on commit 68a9f0a

Please sign in to comment.