Permalink
Browse files

Merge branch 'CL-246'

  • Loading branch information...
2 parents de4f3e9 + f6ab380 commit 2414b8de572fdfbaea0571d9564264e55a5894a7 geremy cohen committed Nov 26, 2012
@@ -20,7 +20,7 @@
#define kMaxHistorySize 100 // From documentation
#define kConnectionTimeOut 310.0 // From https://github.com/jazzychad/CEPubnub/blob/master/CEPubnub/CEPubnubRequest.m
#define kMinRetryInterval 5.0 //In seconds
-#define kMinRetry -1
+#define kMinRetry 3 // -1 for indefinite retry attempts
#define kInitialTimeToken @"0"
typedef enum {
@@ -870,6 +870,22 @@ - (void)handleCommandReceiveMessageForConnection:(PubNubConnection *)connection
}else if(_tryCount <= kMinRetry)
{
[self performSelector:@selector(_resubscribeToChannel:) withObject:connection.channel afterDelay:kMinRetryInterval];
+ }else
+ {
+ for (ChannelStatus* it in [_subscriptions copy]) {
+ if ([it.channel isEqualToString:connection.channel])
+ {
+ it.connected=false;
+ it.first=false;
+ [_subscriptions removeObject:it];
+ break;
+ }
+ }
+ _tryCount=0;
+ [_connections removeObject:connection];
+ if ([_delegate respondsToSelector:@selector(pubnub:maxRetryAttemptCompleted:)]) {
+ [_delegate pubnub:self maxRetryAttemptCompleted:connection.channel];
+ }
}
}
}
@@ -31,6 +31,7 @@
- (void)pubnub:(CEPubnub *)pubnub connectToChannel:(NSString *)channel;
- (void)pubnub:(CEPubnub *)pubnub disconnectFromChannel:(NSString *)channel;
- (void)pubnub:(CEPubnub *)pubnub reconnectToChannel:(NSString *)channel;
+- (void)pubnub:(CEPubnub *)pubnub maxRetryAttemptCompleted:(NSString *)channel;
- (void)pubnub:(CEPubnub *)pubnub presence:(NSDictionary *)message onChannel:(NSString *)channel;
- (void)pubnub:(CEPubnub *)pubnub hereNow:(NSDictionary *)message onChannel:(NSString *)channel;
@@ -283,6 +283,10 @@ - (void)pubnub:(CEPubnub *)pubnub hereNow:(NSDictionary *)message onChannel:(NSS
}
}
+- (void)pubnub:(CEPubnub *)pubnub maxRetryAttemptCompleted:(NSString *)channel
+{
+ NSLog(@"Max Retry Attempt Completed Channel:%@",channel);
+}
@end

1 comment on commit 2414b8d

Contributor

geremyCohen commented on 2414b8d Dec 2, 2012

Because of the nature of the subscribe loop, it by default will retry.

Publishes however will not retry natively from within the API -- it should return a [0, "error message"] upon publish failure, and the host application should key off that to determine the proper logic (retry publish, retry publish n times, report failure to user and schedule publish again in background n seconds later, etc)

geremy

Please sign in to comment.