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

Realtime: dispose method #128

Closed
wants to merge 2 commits into from
Closed
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
3 changes: 3 additions & 0 deletions ably-ios/ARTRealtime.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Instance the Ably library with the given options.
- (BOOL)connect;
- (BOOL)isActive;

/// Explicitly dispose all resources
- (void)dispose;

- (ARTRealtimeConnectionState)state;
- (NSString *)connectionId;
- (NSString *)connectionKey;
Expand Down
16 changes: 14 additions & 2 deletions ably-ios/ARTRealtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ @interface ARTRealtime () <ARTRealtimeTransportDelegate> {
@property (readwrite, assign, nonatomic) int64_t connectionSerial;
@property (readwrite, assign, nonatomic) int64_t msgSerial;

@property (readwrite, strong, nonatomic) NSMutableArray *queuedMessages;
@property (readonly, strong, nonatomic) NSMutableArray *pendingMessages;
/// List of queued messages on a connection in the disconnected or connecting states
@property (readwrite, strong, nonatomic) __GENERIC(NSMutableArray, ARTQueuedMessage*) *queuedMessages;

/// List of pending messages waiting for ACK/NACK action to confirm the success receipt and acceptance
@property (readonly, strong, nonatomic) __GENERIC(NSMutableArray, ARTQueuedMessage*) *pendingMessages;

/// To verify skipped messages, earlier messages... comparing with `msgSerial` response from ACK/NACK action
@property (readwrite, assign, nonatomic) int64_t pendingMessageStartSerial;

@property (nonatomic, copy) ARTRealtimePingCb pingCb;
Expand Down Expand Up @@ -144,6 +149,13 @@ - (instancetype)initWithLogger:(ARTLog *)logger andOptions:(ARTClientOptions *)o
return self;
}

- (void)dispose {
[self.pendingMessages removeAllObjects];
self.pendingMessageStartSerial = 0;
[self removeAllChannels];
[self.eventEmitter removeEvents];
}

- (id<ARTRealtimeTransport>)getTransport {
return _transport;
}
Expand Down