Permalink
Browse files

Clear the socket ID when disconnected.

  • Loading branch information...
1 parent 01beb65 commit c4ed3712ad2bee5c9e754339f1860f15daf788f4 @lukeredpath lukeredpath committed Sep 14, 2011
Showing with 12 additions and 4 deletions.
  1. +1 −1 Library/PTPusherConnection.h
  2. +11 −3 Library/PTPusherConnection.m
@@ -24,7 +24,7 @@
}
@property (nonatomic, assign) id<PTPusherConnectionDelegate> delegate;
@property (nonatomic, readonly, getter=isConnected) BOOL connected;
-@property (nonatomic, readonly) NSString *socketID;
+@property (nonatomic, copy, readonly) NSString *socketID;
///------------------------------------------------------------------------------------/
/// @name Initialisation
@@ -13,6 +13,11 @@
NSString *const PTPusherConnectionEstablishedEvent = @"connection_established";
+@interface PTPusherConnection ()
+@property (nonatomic, copy) NSString *socketID;
+@property (nonatomic, assign, readwrite) BOOL connected;
+@end
+
@implementation PTPusherConnection
@synthesize delegate = _delegate;
@@ -72,7 +77,9 @@ - (void)webSocket:(ZTWebSocket*)webSocket didFailWithError:(NSError*)error;
- (void)webSocketDidClose:(ZTWebSocket*)webSocket;
{
- connected = NO;
+ self.connected = NO;
+ self.socketID = nil;
+
[self.delegate pusherConnectionDidDisconnect:self];
}
@@ -82,8 +89,9 @@ - (void)webSocket:(ZTWebSocket*)webSocket didReceiveMessage:(NSString*)message;
PTPusherEvent *event = [PTPusherEvent eventFromMessageDictionary:messageDictionary];
if ([event.name isEqualToString:PTPusherConnectionEstablishedEvent]) {
- socketID = [[event.data objectForKey:@"socket_id"] copy];
- connected = YES;
+ self.socketID = [event.data objectForKey:@"socket_id"];
+ self.connected = YES;
+
[self.delegate pusherConnectionDidConnect:self];
}
[self.delegate pusherConnection:self didReceiveEvent:event];

0 comments on commit c4ed371

Please sign in to comment.