Skip to content

Commit c4ed371

Browse files
committed
Clear the socket ID when disconnected.
1 parent 01beb65 commit c4ed371

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Library/PTPusherConnection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
}
2525
@property (nonatomic, assign) id<PTPusherConnectionDelegate> delegate;
2626
@property (nonatomic, readonly, getter=isConnected) BOOL connected;
27-
@property (nonatomic, readonly) NSString *socketID;
27+
@property (nonatomic, copy, readonly) NSString *socketID;
2828

2929
///------------------------------------------------------------------------------------/
3030
/// @name Initialisation

Library/PTPusherConnection.m

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313

1414
NSString *const PTPusherConnectionEstablishedEvent = @"connection_established";
1515

16+
@interface PTPusherConnection ()
17+
@property (nonatomic, copy) NSString *socketID;
18+
@property (nonatomic, assign, readwrite) BOOL connected;
19+
@end
20+
1621
@implementation PTPusherConnection
1722

1823
@synthesize delegate = _delegate;
@@ -72,7 +77,9 @@ - (void)webSocket:(ZTWebSocket*)webSocket didFailWithError:(NSError*)error;
7277

7378
- (void)webSocketDidClose:(ZTWebSocket*)webSocket;
7479
{
75-
connected = NO;
80+
self.connected = NO;
81+
self.socketID = nil;
82+
7683
[self.delegate pusherConnectionDidDisconnect:self];
7784
}
7885

@@ -82,8 +89,9 @@ - (void)webSocket:(ZTWebSocket*)webSocket didReceiveMessage:(NSString*)message;
8289
PTPusherEvent *event = [PTPusherEvent eventFromMessageDictionary:messageDictionary];
8390

8491
if ([event.name isEqualToString:PTPusherConnectionEstablishedEvent]) {
85-
socketID = [[event.data objectForKey:@"socket_id"] copy];
86-
connected = YES;
92+
self.socketID = [event.data objectForKey:@"socket_id"];
93+
self.connected = YES;
94+
8795
[self.delegate pusherConnectionDidConnect:self];
8896
}
8997
[self.delegate pusherConnection:self didReceiveEvent:event];

0 commit comments

Comments
 (0)