Skip to content

Commit

Permalink
Fix spec RTP17g
Browse files Browse the repository at this point in the history
  • Loading branch information
QSD_igor committed Nov 11, 2022
1 parent 437bb08 commit 28531da
Showing 1 changed file with 29 additions and 10 deletions.
39 changes: 29 additions & 10 deletions core/src/main/java/io/ably/lib/realtime/Presence.java
Original file line number Diff line number Diff line change
Expand Up @@ -986,16 +986,35 @@ synchronized void clear() {
* Spec: RTP17g
*/
synchronized void reEnter() {
for (Map.Entry<String, PresenceMessage> entry: members.entrySet()) {
PresenceMessage member = entry.getValue();
member.action = PresenceMessage.Action.enter;
try {
updatePresence(member, null);
} catch (AblyException e) {
String errorString = String.format(Locale.ROOT, "Cannot automatically re-enter %s on channel %s (%s)",
member.clientId, channel.name, e.errorInfo.message);
Log.e(TAG, errorString);
channel.emitUpdate(new ErrorInfo(errorString, 91004), true);
for (PresenceMessage item: internalPresence.values()) {
if (presence.put(item)) {
/* Message is new to presence map, send it */
final String clientId = item.clientId;
try {
PresenceMessage itemToSend = new PresenceMessage();
itemToSend.id = item.id;
itemToSend.clientId = item.clientId;
itemToSend.data = item.data;
itemToSend.action = PresenceMessage.Action.enter;
updatePresence(itemToSend, new CompletionListener() {
@Override
public void onSuccess() {
}

@Override
public void onError(ErrorInfo reason) {
String errorString = String.format(Locale.ROOT, "Cannot automatically re-enter %s on channel %s (%s)",
clientId, channel.name, reason.message);
Log.e(TAG, errorString);
channel.emitUpdate(new ErrorInfo(errorString, 91004), true);
}
});
} catch(AblyException e) {
String errorString = String.format(Locale.ROOT, "Cannot automatically re-enter %s on channel %s (%s)",
clientId, channel.name, e.errorInfo.message);
Log.e(TAG, errorString);
channel.emitUpdate(new ErrorInfo(errorString, 91004), true);
}
}
}
}
Expand Down

0 comments on commit 28531da

Please sign in to comment.