|
@@ -362,7 +362,7 @@ NSString *const SRHTTPResponseErrorKey = @"HTTPResponseStatusCode";
|
|
|
// Schedule to run on a work queue, to make sure we don't run this inline and deallocate `self` inside `SRProxyConnect`.
|
|
|
// TODO: (nlutsenko) Find a better structure for this, maybe Bolts Tasks?
|
|
|
dispatch_async(_workQueue, ^{
|
|
|
- _proxyConnect = nil;
|
|
|
+ self->_proxyConnect = nil;
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -431,10 +431,11 @@ NSString *const SRHTTPResponseErrorKey = @"HTTPResponseStatusCode";
|
|
|
}
|
|
|
|
|
|
[self _readUntilHeaderCompleteWithCallback:^(SRWebSocket *socket, NSData *data) {
|
|
|
- CFHTTPMessageAppendBytes(_receivedHTTPHeaders, (const UInt8 *)data.bytes, data.length);
|
|
|
+ CFHTTPMessageRef receivedHeaders = self->_receivedHTTPHeaders;
|
|
|
+ CFHTTPMessageAppendBytes(receivedHeaders, (const UInt8 *)data.bytes, data.length);
|
|
|
|
|
|
- if (CFHTTPMessageIsHeaderComplete(_receivedHTTPHeaders)) {
|
|
|
- SRDebugLog(@"Finished reading headers %@", CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(_receivedHTTPHeaders)));
|
|
|
+ if (CFHTTPMessageIsHeaderComplete(receivedHeaders)) {
|
|
|
+ SRDebugLog(@"Finished reading headers %@", CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(receivedHeaders)));
|
|
|
[self _HTTPHeadersDidFinish];
|
|
|
} else {
|
|
|
[self _readHTTPHeader];
|
|
@@ -550,7 +551,7 @@ NSString *const SRHTTPResponseErrorKey = @"HTTPResponseStatusCode";
|
|
|
// Need to shunt this on the _callbackQueue first to see if they received any messages
|
|
|
[self.delegateController performDelegateQueueBlock:^{
|
|
|
[self closeWithCode:SRStatusCodeProtocolError reason:message];
|
|
|
- dispatch_async(_workQueue, ^{
|
|
|
+ dispatch_async(self->_workQueue, ^{
|
|
|
[self closeConnection];
|
|
|
});
|
|
|
}];
|
|
@@ -560,7 +561,7 @@ NSString *const SRHTTPResponseErrorKey = @"HTTPResponseStatusCode";
|
|
|
{
|
|
|
dispatch_async(_workQueue, ^{
|
|
|
if (self.readyState != SR_CLOSED) {
|
|
|
- _failed = YES;
|
|
|
+ self->_failed = YES;
|
|
|
[self.delegateController performDelegateBlock:^(id<SRWebSocketDelegate> _Nullable delegate, SRDelegateAvailableMethods availableMethods) {
|
|
|
if (availableMethods.didFailWithError) {
|
|
|
[delegate webSocket:self didFailWithError:error];
|
|
@@ -676,7 +677,7 @@ NSString *const SRHTTPResponseErrorKey = @"HTTPResponseStatusCode";
|
|
|
if (availableMethods.didReceivePing) {
|
|
|
[delegate webSocket:self didReceivePingWithData:data];
|
|
|
}
|
|
|
- dispatch_async(_workQueue, ^{
|
|
|
+ dispatch_async(self->_workQueue, ^{
|
|
|
[self _sendFrameWithOpcode:SROpCodePong data:data];
|
|
|
});
|
|
|
}];
|
|
@@ -977,7 +978,7 @@ static const uint8_t SRPayloadLenMask = 0x7F;
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- size_t extra_bytes_needed = header.masked ? sizeof(_currentReadMaskKey) : 0;
|
|
|
+ size_t extra_bytes_needed = header.masked ? sizeof(sself->_currentReadMaskKey) : 0;
|
|
|
|
|
|
if (header.payload_length == 126) {
|
|
|
extra_bytes_needed += sizeof(uint16_t);
|
|
@@ -1015,7 +1016,7 @@ static const uint8_t SRPayloadLenMask = 0x7F;
|
|
|
}
|
|
|
|
|
|
if (header.masked) {
|
|
|
- assert(mapped_size >= sizeof(_currentReadMaskOffset) + offset);
|
|
|
+ assert(mapped_size >= sizeof(eself->_currentReadMaskOffset) + offset);
|
|
|
memcpy(eself->_currentReadMaskKey, ((uint8_t *)mapped_buffer) + offset, sizeof(eself->_currentReadMaskKey));
|
|
|
}
|
|
|
|
|
@@ -1030,12 +1031,12 @@ static const uint8_t SRPayloadLenMask = 0x7F;
|
|
|
dispatch_async(_workQueue, ^{
|
|
|
// Don't reset the length, since Apple doesn't guarantee that this will free the memory (and in tests on
|
|
|
// some platforms, it doesn't seem to, effectively causing a leak the size of the biggest frame so far).
|
|
|
- _currentFrameData = [[NSMutableData alloc] init];
|
|
|
+ self->_currentFrameData = [[NSMutableData alloc] init];
|
|
|
|
|
|
- _currentFrameOpcode = 0;
|
|
|
- _currentFrameCount = 0;
|
|
|
- _readOpCount = 0;
|
|
|
- _currentStringScanPosition = 0;
|
|
|
+ self->_currentFrameOpcode = 0;
|
|
|
+ self->_currentFrameCount = 0;
|
|
|
+ self->_readOpCount = 0;
|
|
|
+ self->_currentStringScanPosition = 0;
|
|
|
|
|
|
[self _readFrameContinue];
|
|
|
});
|
|
@@ -1097,7 +1098,7 @@ static const uint8_t SRPayloadLenMask = 0x7F;
|
|
|
if (!_failed) {
|
|
|
[self.delegateController performDelegateBlock:^(id<SRWebSocketDelegate> _Nullable delegate, SRDelegateAvailableMethods availableMethods) {
|
|
|
if (availableMethods.didCloseWithCode) {
|
|
|
- [delegate webSocket:self didCloseWithCode:_closeCode reason:_closeReason wasClean:YES];
|
|
|
+ [delegate webSocket:self didCloseWithCode:self->_closeCode reason:self->_closeReason wasClean:YES];
|
|
|
}
|
|
|
}];
|
|
|
}
|
|
@@ -1159,7 +1160,7 @@ static const uint8_t SRPayloadLenMask = 0x7F;
|
|
|
|
|
|
// Cleanup selfRetain in the same GCD queue as usual
|
|
|
dispatch_async(_workQueue, ^{
|
|
|
- _selfRetain = nil;
|
|
|
+ self->_selfRetain = nil;
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -1471,8 +1472,8 @@ static const size_t SRFrameHeaderOverhead = 32;
|
|
|
[self _scheduleCleanup];
|
|
|
}
|
|
|
|
|
|
- if (!_sentClose && !_failed) {
|
|
|
- _sentClose = YES;
|
|
|
+ if (!self->_sentClose && !self->_failed) {
|
|
|
+ self->_sentClose = YES;
|
|
|
// If we get closed in this state it's probably not clean because we should be sending this when we send messages
|
|
|
[self.delegateController performDelegateBlock:^(id<SRWebSocketDelegate> _Nullable delegate, SRDelegateAvailableMethods availableMethods) {
|
|
|
if (availableMethods.didCloseWithCode) {
|