-
Notifications
You must be signed in to change notification settings - Fork 0
Revert "Fix a crash on Android" #15
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
base: dragons3d_master
Are you sure you want to change the base?
Changes from all commits
8025f2d
273334f
c13cc14
80c7cc6
8459ff0
e187de7
f41edc0
c402a11
5def595
05eb350
b1fe272
87dcb6b
6ef0d48
70718fc
5c240a2
2340a79
3c9f586
a7678c3
1380f6b
0b1fe56
7001666
f4f980d
86c2eb7
bcf9b35
c179213
04b664e
0080e68
ac3cfd7
8f6137a
b3d702b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,10 @@ | |
| #import <objc/runtime.h> | ||
| #import "PNHelpers.h" | ||
|
|
||
| #ifdef PGDROID | ||
| #import <UIKit/UIKit.h> | ||
| #endif | ||
|
|
||
|
|
||
| #pragma mark Static | ||
|
|
||
|
|
@@ -566,7 +570,7 @@ - (void)updateStateTo:(PNSubscriberState)state withStatus:(PNSubscribeStatus *)s | |
| currentState == PNConnectedSubscriberState); | ||
| category = ((targetState == PNDisconnectedSubscriberState) ? PNDisconnectedCategory : | ||
| PNUnexpectedDisconnectCategory); | ||
| self.mayRequireSubscriptionRestore = shouldHandleTransition; | ||
| self.mayRequireSubscriptionRestore = YES; | ||
| } | ||
| // Check whether transit to 'access denied' state. | ||
| else if (targetState == PNAccessRightsErrorSubscriberState) { | ||
|
|
@@ -628,6 +632,10 @@ - (instancetype)initForClient:(PubNub *)client { | |
| _presenceChannelsSet = [NSMutableSet new]; | ||
| _resourceAccessQueue = dispatch_queue_create("com.pubnub.subscriber", | ||
| DISPATCH_QUEUE_CONCURRENT); | ||
| [[NSNotificationCenter defaultCenter] addObserver:self | ||
| selector:@selector(didEnterBackground) | ||
| name:UIApplicationDidEnterBackgroundNotification | ||
| object:nil]; | ||
| } | ||
|
|
||
| return self; | ||
|
|
@@ -718,25 +726,31 @@ - (void)restoreSubscriptionCycleIfRequiredWithCompletion:(PNSubscriberCompletion | |
|
|
||
| __block BOOL shouldRestore; | ||
| __block BOOL ableToRestore; | ||
| DDLogAPICall([[self class] ddLogLevel], @"Called restore subscription cycle with block: %@", block); | ||
|
|
||
| __weak __typeof(self) weakSelf = self; | ||
| dispatch_sync(self.resourceAccessQueue, ^{ | ||
|
|
||
| __strong __typeof(self) self = weakSelf; | ||
| DDLogAPICall([[self class] ddLogLevel], @"Checking if should and able to restore subscription cycle with block: %@", block); | ||
| shouldRestore = (self.currentState == PNDisconnectedUnexpectedlySubscriberState && | ||
| self.mayRequireSubscriptionRestore); | ||
| ableToRestore = ([self.channelsSet count] || [self.channelGroupsSet count] || | ||
| [self.presenceChannelsSet count]); | ||
| }); | ||
| if (shouldRestore && ableToRestore) { | ||
|
|
||
| DDLogAPICall([[self class] ddLogLevel], @"Restoring subscription cycle with block: %@", block); | ||
| [self subscribe:YES withState:nil completion:block]; | ||
| } | ||
| else if (block) { | ||
|
|
||
| block(nil); | ||
| } else { | ||
| DDLogAPICall([[self class] ddLogLevel], @"Not restoring subscription cycle with block (%d, %d): %@", shouldRestore, ableToRestore, block); | ||
| if (block) { | ||
| block(nil); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| - (void)continueSubscriptionCycleIfRequiredWithCompletion:(PNSubscriberCompletionBlock)block { | ||
|
|
||
| DDLogAPICall([[self class] ddLogLevel], @"Continuing subscription cycle with block: %@", block); | ||
| [self subscribe:NO withState:nil completion:block]; | ||
| } | ||
|
|
||
|
|
@@ -894,7 +908,6 @@ - (void)handleSuccessSubscriptionStatus:(PNSubscribeStatus *)status { | |
| } | ||
|
|
||
| - (void)handleFailedSubscriptionStatus:(PNSubscribeStatus *)status { | ||
|
|
||
| // Silence static analyzer warnings. | ||
| // Code is aware about this case and at the end will simply call on 'nil' object method. | ||
| // In most cases if referenced object become 'nil' it mean what there is no more need in | ||
|
|
@@ -1051,6 +1064,7 @@ - (void)handleLiveFeedEvents:(PNSubscribeStatus *)status { | |
| // it and probably whole client instance has been deallocated. | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wreceiver-is-weak" | ||
| PNSubscribeStatus *copiedStatus = [status copy]; | ||
| [self.client.listenersManager notifyWithBlock:^{ | ||
|
|
||
| // Iterate through array with notifications and report back using callback blocks to the | ||
|
|
@@ -1078,7 +1092,7 @@ - (void)handleLiveFeedEvents:(PNSubscribeStatus *)status { | |
| } | ||
| } | ||
|
|
||
| id eventResultObject = [status copyWithMutatedData:event]; | ||
| id eventResultObject = [copiedStatus copyWithMutatedData:event]; | ||
| if (isPresenceEvent) { | ||
|
|
||
| object_setClass(eventResultObject, [PNPresenceEventResult class]); | ||
|
|
@@ -1212,7 +1226,11 @@ - (void)appendSubscriberInformation:(PNStatus *)status { | |
| status.subscribedChannelGroups = [_channelGroupsSet allObjects]; | ||
| } | ||
|
|
||
| #pragma mark - | ||
| #pragma mark - Internal | ||
| - (void)didEnterBackground { | ||
| [self.client.heartbeatManager stopHeartbeatIfPossible]; | ||
| [self stopRetryTimer]; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this start when the game reenters the foreground?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not quite sure about how it works but when I set a breakpoint at startHeartbeat it get called when the game comes back. The stack trace shows this is triggered by some callback. |
||
| } | ||
|
|
||
|
|
||
| @end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this import?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XCode complains the UIApplication notification is not defined.
I checked in our code base and saw Orlando did something like this elsewhere.