Skip to content

Commit

Permalink
Implemented channel serial for message reeived
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Nov 29, 2023
1 parent 130305b commit 3c04523
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/src/main/java/io/ably/lib/realtime/ChannelBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.ably.lib.util.EventEmitter;
import io.ably.lib.util.Log;
import io.ably.lib.util.ReconnectionStrategy;
import io.ably.lib.util.StringUtils;

/**
* Enables messages to be published and subscribed to.
Expand Down Expand Up @@ -248,8 +249,9 @@ private void attachImpl(final boolean forceReattach, final CompletionListener li
}
}
if(this.decodeFailureRecoveryInProgress) {
attachMessage.channelSerial = this.lastPayloadProtocolMessageChannelSerial;
Log.v(TAG, "attach(); message decode recovery in progress.");
}
attachMessage.channelSerial = properties.channelSerial;
try {
if (listener != null) {
on(new ChannelStateCompletionListener(listener, ChannelState.attached, ChannelState.failed));
Expand Down Expand Up @@ -850,7 +852,6 @@ private void onMessage(final ProtocolMessage protocolMessage) {
}

lastPayloadMessageId = lastMessage.id;
lastPayloadProtocolMessageChannelSerial = protocolMessage.channelSerial;

for (final Message msg : messages) {
this.listeners.onMessage(msg);
Expand Down Expand Up @@ -1264,6 +1265,15 @@ else if(stateChange.current.equals(failureState)) {
}

void onChannelMessage(ProtocolMessage msg) {
// RTL15b
if (!StringUtils.isNullOrEmpty(msg.channelSerial) && (msg.action == Action.message ||
msg.action == Action.presence || msg.action == Action.attached)) {
Log.v(TAG, String.format(
Locale.ROOT, "Setting channel serial for channelName - %s, previous - %s, current - %s",
name, properties.channelSerial, msg.channelSerial));
properties.channelSerial = msg.channelSerial;
}

switch(msg.action) {
case attached:
setAttached(msg);
Expand Down Expand Up @@ -1369,7 +1379,6 @@ public void once(ChannelState state, ChannelStateListener listener) {
*/
private Set<ChannelMode> modes;
private String lastPayloadMessageId;
private String lastPayloadProtocolMessageChannelSerial;
private boolean decodeFailureRecoveryInProgress;
private final DecodingContext decodingContext;
}

0 comments on commit 3c04523

Please sign in to comment.