Correctly reset the websocket in all cases

Signed-off-by: Marcel Müller <marcel-mueller@gmx.de>
This commit is contained in:
Marcel Müller 2022-12-11 10:30:18 +01:00
Родитель 8b8f3e1264
Коммит c3d3db6d4a
1 изменённых файлов: 12 добавлений и 9 удалений

Просмотреть файл

@ -159,11 +159,7 @@ static NSTimeInterval kWebSocketTimeoutInterval = 15;
[self executeAllCompletionBlocksWithError];
[_webSocket cancel];
_webSocket = nil;
_helloResponseReceived = NO;
[_helloMessage ignoreCompletionBlock];
_helloMessage = nil;
[self resetWebSocket];
[self setReconnectionTimer];
}
@ -180,13 +176,20 @@ static NSTimeInterval kWebSocketTimeoutInterval = 15;
{
dispatch_async(dispatch_get_main_queue(), ^{
[self invalidateReconnectionTimer];
[self->_webSocket cancel];
self->_webSocket = nil;
self->_helloResponseReceived = NO;
self->_disconnected = YES;
[self resetWebSocket];
});
}
- (void)resetWebSocket
{
[_webSocket cancel];
_webSocket = nil;
_helloResponseReceived = NO;
[_helloMessage ignoreCompletionBlock];
_helloMessage = nil;
_disconnected = YES;
}
- (void)setReconnectionTimer
{
[self invalidateReconnectionTimer];