Skip to content

Commit 1fe150f

Browse files
author
jenkins
committed
Updated Diffusion Examples to 6.9.0
1 parent e655db2 commit 1fe150f

95 files changed

Lines changed: 1990 additions & 1135 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

apple/AuthenticatedConnectionExample.m renamed to apple/Connecting/AuthenticatedConnectionExample.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
22
//
3-
// Copyright (C) 2015, 2018 Push Technology Ltd.
3+
// Copyright (C) 2015 - 2022 Push Technology Ltd.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
22
//
3-
// Copyright (C) 2015, 2018 Push Technology Ltd.
3+
// Copyright (C) 2015 - 2022 Push Technology Ltd.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

apple/CustomReconnectionStrategyExample.m renamed to apple/Connecting/CustomReconnectionStrategyExample.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
22
//
3-
// Copyright (C) 2016, 2018 Push Technology Ltd.
3+
// Copyright (C) 2016 - 2022 Push Technology Ltd.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
2+
//
3+
// Copyright (C) 2022 Push Technology Ltd.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
#import "InitialSessionEstablishmentRetryStrategy.h"
17+
18+
@import Diffusion;
19+
20+
@implementation InitialSessionEstablishmentRetryStrategy {
21+
PTDiffusionSession* _session;
22+
}
23+
24+
-(void)startWithURL:(NSURL*)url {
25+
26+
NSLog(@"Connecting...");
27+
28+
PTDiffusionMutableSessionConfiguration *const configuration = [[PTDiffusionMutableSessionConfiguration alloc] init];
29+
30+
// Create an initial session establishment retry strategy.
31+
// It will attempt 10 times to connect to the Diffusion server, with 500 milliseconds interval between attempts.
32+
configuration.initialRetryStrategy = [[PTDiffusionRetryStrategy alloc] initWithInterval:500 andAttempts:10];
33+
34+
[PTDiffusionSession openWithURL:url
35+
configuration:configuration
36+
completionHandler:^(PTDiffusionSession *session, NSError *error)
37+
{
38+
if (!session) {
39+
NSLog(@"Failed to open session: %@", error);
40+
return;
41+
}
42+
43+
// At this point we now have a connected session.
44+
NSLog(@"Connected. Session Identifier: %@", session.sessionId);
45+
46+
// Set ivar to maintain a strong reference to the session.
47+
self->_session = session;
48+
}];
49+
}
50+
51+
@end

apple/Features/Metrics/TopicMetricCollectorExample.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
22
//
3-
// Copyright (C) 2021 Push Technology Ltd.
3+
// Copyright (C) 2021 - 2022 Push Technology Ltd.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.
@@ -49,10 +49,11 @@ -(void)startWithURL:(NSURL*)url {
4949

5050
// create a topic metric collector using its builder
5151
PTDiffusionTopicMetricCollector *const collector =
52-
[[[[[PTDiffusionTopicMetricCollectorBuilder new]
53-
exportToPrometheus:NO]
54-
maximumGroups:10]
55-
groupByTopicType:YES]
52+
[[[[[[PTDiffusionTopicMetricCollectorBuilder new]
53+
exportToPrometheus:NO]
54+
maximumGroups:10]
55+
groupByTopicType:YES]
56+
groupByTopicView:YES]
5657
createCollectorWithName:@"collector 1" andTopicSelector:@"*A/B/C//"];
5758

5859
PTDiffusionMetricsFeature *const metrics = session.metrics;
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
2+
//
3+
// Copyright (C) 2022 Push Technology Ltd.
4+
//
5+
// Licensed under the Apache License, Version 2.0 (the "License");
6+
// you may not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
#import "UpdateStreamBuilderExample.h"
17+
18+
@import Diffusion;
19+
20+
21+
@implementation UpdateStreamBuilderExample{
22+
PTDiffusionSession* _session;
23+
}
24+
25+
-(void)startWithURL:(NSURL*)url {
26+
27+
PTDiffusionCredentials *const credentials =
28+
[[PTDiffusionCredentials alloc] initWithPassword:@"password"];
29+
30+
PTDiffusionSessionConfiguration *const sessionConfiguration =
31+
[[PTDiffusionSessionConfiguration alloc] initWithPrincipal:@"admin"
32+
credentials:credentials];
33+
34+
NSLog(@"Connecting...");
35+
36+
[PTDiffusionSession openWithURL:url
37+
configuration:sessionConfiguration
38+
completionHandler:^(PTDiffusionSession *const session, NSError *const error)
39+
{
40+
if (!session) {
41+
NSLog(@"Failed to open session: %@", error);
42+
return;
43+
}
44+
45+
// At this point we now have a connected session.
46+
NSLog(@"Connected.");
47+
48+
// Set ivar to maintain a strong reference to the session.
49+
self->_session = session;
50+
51+
// create an update stream builder
52+
PTDiffusionUpdateStreamBuilder *const builder = [session.topicUpdate newUpdateStreamBuilder];
53+
54+
// create the Topic Specification and set the Update Stream Builder to it
55+
PTDiffusionTopicSpecification * const specification = [[PTDiffusionTopicSpecification alloc] initWithType:PTDiffusionTopicType_JSON];
56+
[builder topicSpecification:specification];
57+
58+
// create an Update Stream
59+
PTDiffusionJSONUpdateStream *const updateStream = [builder jsonUpdateStreamWithPath:@"a/b/c"];
60+
61+
// use the update stream to create and set the topic value
62+
PTDiffusionJSON *value = [[PTDiffusionJSON alloc] initWithJSONString:@"{\"hello\": \"world\"}" error:nil];
63+
[updateStream setValue:value
64+
completionHandler:^(PTDiffusionTopicCreationResult * _Nullable result, NSError * _Nullable error) {
65+
if (result != nil) {
66+
NSLog(@"Topic has been updated!");
67+
}
68+
}
69+
error:nil];
70+
}];
71+
}
72+
73+
@end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
22
//
3-
// Copyright (C) 2016, 2018 Push Technology Ltd.
3+
// Copyright (C) 2016 - 2022 Push Technology Ltd.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

apple/CreatingRecordV2SchemaExample.m renamed to apple/Publish/CreatingRecordV2SchemaExample.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
22
//
3-
// Copyright (C) 2017 Push Technology Ltd.
3+
// Copyright (C) 2017 - 2022 Push Technology Ltd.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

apple/CreatingRecordV2SchemaExample.swift renamed to apple/Publish/CreatingRecordV2SchemaExample.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
22
//
3-
// Copyright (C) 2017 Push Technology Ltd.
3+
// Copyright (C) 2017 - 2022 Push Technology Ltd.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Diffusion Client Library for iOS, tvOS and OS X / macOS - Examples
22
//
3-
// Copyright (C) 2016, 2019 Push Technology Ltd.
3+
// Copyright (C) 2016 - 2022 Push Technology Ltd.
44
//
55
// Licensed under the Apache License, Version 2.0 (the "License");
66
// you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)