Skip to content

Commit

Permalink
pass agent param when fetching realtime channel
Browse files Browse the repository at this point in the history
TODO test
  • Loading branch information
lawrence-forooghian committed Jan 22, 2025
1 parent a98b361 commit 67669b7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/ARTClientInformation.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ + (NSString *)agentIdentifierWithAdditionalAgents:(nullable NSDictionary<NSStrin
for (NSString *const additionalAgentName in additionalAgents) {
agents[additionalAgentName] = additionalAgents[additionalAgentName];
}

return [self agentIdentifierForAgents:agents];
}

Expand Down
19 changes: 17 additions & 2 deletions Source/ARTRealtimeWrapperSDKProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#import "ARTRealtimeWrapperSDKProxy+Private.h"
#import "ARTWrapperProxyOptions.h"
#import "ARTRealtime+Private.h"
#import "ARTRealtimeChannelOptions.h"
#import "ARTClientInformation+Private.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -145,16 +147,29 @@ - (void)release:(nonnull NSString *)name callback:(nullable ARTCallback)errorInf
[self.channels release:name callback:errorInfo];
}

- (ARTRealtimeChannelOptions *)addingAgentToOptions:(ARTRealtimeChannelOptions *)options {
NSMutableDictionary<NSString *, NSString *> *resolvedParams = options.params ? [options.params mutableCopy] : [NSMutableDictionary dictionary];
if (self.options.agents) {
resolvedParams[@"agent"] = [ARTClientInformation agentIdentifierForAgents:self.options.agents];
}

ARTRealtimeChannelOptions *resolvedOptions = options ? [options copy] : [[ARTRealtimeChannelOptions alloc] init];
resolvedOptions.params = resolvedParams;

return resolvedOptions;
}

- (ARTRealtimeWrapperSDKChannelProxy *)get:(NSString *)name {
ARTRealtimeChannel *channel = [self.channels get:name];
ARTRealtimeChannel *channel = [self.channels get:name
options:[self addingAgentToOptions:nil]];
// TODO reuse existing instance
return [[ARTRealtimeWrapperSDKChannelProxy alloc] initWithChannel:channel
options:self.options];
}

- (ARTRealtimeWrapperSDKChannelProxy *)get:(NSString *)name options:(ARTRealtimeChannelOptions *)options {
ARTRealtimeChannel *channel = [self.channels get:name
options:options];
options:[self addingAgentToOptions:options]];
// TODO reuse existing instance
return [[ARTRealtimeWrapperSDKChannelProxy alloc] initWithChannel:channel
options:self.options];
Expand Down
3 changes: 3 additions & 0 deletions Source/PrivateHeaders/Ably/ARTClientInformation+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ extern NSString *const ARTClientInformation_libraryVersion;
+ (NSString *)libraryAgentIdentifier;
+ (NSString *)platformAgentIdentifier;

// The resulting string only includes the given agents; it does not insert any default agents.
+ (NSString *)agentIdentifierForAgents:(NSDictionary<NSString *, NSString*> *)agents;

@end

NS_ASSUME_NONNULL_END

0 comments on commit 67669b7

Please sign in to comment.