Skip to content

Conversation

Copy link

Copilot AI commented Aug 29, 2025

This PR adds the ability to control attach resume behavior on a per-channel basis, allowing clients to disable automatic resume and rely solely on message history when channels reconnect within the 2-minute TTL.

Problem

Previously, attach resume behavior was managed automatically at the channel level based on state transitions. Clients had no way to override this behavior for specific channels, meaning they would always receive missed messages during reconnection within the TTL period. Some use cases require disabling this behavior to rely exclusively on message history.

Solution

Added a new attachResume property to ARTRealtimeChannelOptions:

@property (nonatomic, nullable) NSNumber *attachResume;

The property behavior:

  • nil (default): Uses existing automatic behavior based on channel state
  • @YES: Forces attach resume to be enabled
  • @NO: Forces attach resume to be disabled, allowing sole reliance on message history

Usage Example

// Disable attach resume for this channel
ARTRealtimeChannelOptions *options = [[ARTRealtimeChannelOptions alloc] init];
options.attachResume = @NO;

ARTRealtimeChannel *channel = [client.channels get:@"channel-name" options:options];
// This channel will not use attach resume and will rely on message history

Message Differentiation

The existing ARTChannelStateChange.resumed property can be used to differentiate between messages received during normal operation vs. after a resumed attachment:

[channel on:ARTChannelEventAttached callback:^(ARTChannelStateChange *stateChange) {
    if (stateChange.resumed) {
        // Messages received shortly after are from resume
    }
}];

Implementation Details

  • Added new property to ARTRealtimeChannelOptions with proper getter/setter and copy support
  • Modified attach logic to use shouldUseAttachResume helper method that checks channel options
  • Maintains full backward compatibility - existing behavior unchanged when property is nil
  • Added comprehensive tests covering all three scenarios (enabled, disabled, default)

Fixes #2042.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copy link
Author

Copilot AI commented Aug 29, 2025

@umair-ably 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Copilot AI changed the title [WIP] Disable fromResume on a channel basis to allow sole reliance on message history. Add per-channel attachResume control to ARTRealtimeChannelOptions Aug 29, 2025
Copilot AI requested a review from umair-ably August 29, 2025 12:55
Copilot finished work on behalf of umair-ably August 29, 2025 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Disable fromResume on a channel basis to allow sole reliance on message history.

2 participants