Last active
August 29, 2015 14:24
-
-
Save seaders/644a61cb7e3b3a899aeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -r 983242b3e120 -r be189741ef87 PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.h | |
--- a/PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.h Thu May 14 11:57:01 2015 +0100 | |
+++ b/PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.h Wed May 27 12:14:52 2015 +0300 | |
@@ -22,6 +22,7 @@ | |
@property (readonly, nonatomic) void* udata; | |
@property (nonatomic) BOOL shouldAbort; | |
+@property (atomic) BOOL done; | |
@end | |
diff -r 983242b3e120 -r be189741ef87 PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.mm | |
--- a/PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.mm Thu May 14 11:57:01 2015 +0100 | |
+++ b/PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.mm Wed May 27 12:14:52 2015 +0300 | |
@@ -126,6 +126,10 @@ | |
// on ios pre-5.0 NSHTTPURLResponse was not created for "file://"" connections, so play safe here | |
// TODO: remove that once we have 5.0 as requirement | |
self->_status = 200; | |
+ | |
+ long long contentLength = [response expectedContentLength]; | |
+ self->_estimatedLength = contentLength > 0 ? contentLength : 0; | |
+ | |
if([response isMemberOfClass:[NSHTTPURLResponse class]]) | |
{ | |
NSDictionary* respHeader = [(NSHTTPURLResponse*)response allHeaderFields]; | |
@@ -140,9 +144,6 @@ | |
self->_responseHeader = headerString; | |
self->_status = (int)[(NSHTTPURLResponse*)response statusCode]; | |
- long long contentLength = [response expectedContentLength]; | |
- self->_estimatedLength = contentLength > 0 ? contentLength : 0; | |
- | |
// status 2xx are all success | |
if(self->_status / 100 != 2) | |
{ | |
@@ -172,11 +173,13 @@ | |
- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error | |
{ | |
UnityReportWWWFailedWithError(self.udata, [[error localizedDescription] UTF8String]); | |
+ self.done = YES; | |
} | |
- (void)connectionDidFinishLoading:(NSURLConnection*)connection | |
{ | |
self.connection = nil; | |
UnityReportWWWFinishedLoadingData(self.udata); | |
+ self.done = YES; | |
} | |
- (void)connection:(NSURLConnection*)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite | |
diff -r 983242b3e120 -r be189741ef87 PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.mm | |
--- a/PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.mm Thu May 14 11:57:01 2015 +0100 | |
+++ b/PlatformDependent/iPhonePlayer/iPhone-Trampoline/Classes/Unity/WWWConnection.mm Wed May 27 12:14:52 2015 +0300 | |
@@ -268,7 +271,17 @@ | |
[request setHTTPBody:[NSData dataWithBytes:data length:length]]; | |
[request setValue:[NSString stringWithFormat:@"%d", length] forHTTPHeaderField:@"Content-Length"]; | |
- delegate.connection = [NSURLConnection connectionWithRequest:request delegate:delegate]; | |
+ delegate.connection = [[NSURLConnection alloc] initWithRequest:request delegate:delegate startImmediately:NO]; | |
+ | |
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
+ //[[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantFuture]]; | |
+ [delegate.connection start]; | |
+ | |
+ while(!delegate.done) { | |
+ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; | |
+ } | |
+ }); | |
+ | |
return (__bridge_retained void*)delegate; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment