Permalink
Browse files

CL-246: Add Max retry attempt completed delegate.

  • Loading branch information...
1 parent 61b23fb commit f6ab380a4ca56a239f810eb54bfb2b65b6b9f626 @tanaji-kadam tanaji-kadam committed Nov 2, 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 {
@@ -853,6 +853,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

0 comments on commit f6ab380

Please sign in to comment.