Skip to content

Commit

Permalink
#116 corrects eventSource retain count
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Billingsley committed Jan 16, 2013
1 parent ccb9753 commit b59a67b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions SignalR.Client/Transports/SRServerSentEventsTransport.m
Expand Up @@ -79,7 +79,8 @@ - (void)openConnection:(SRConnection *)connection data:(NSString *)data initiali

NSString *url = [(_reconnecting ? connection.url : [connection.url stringByAppendingString:@"connect"]) stringByAppendingFormat:@"%@",[self getReceiveQueryString:connection data:data]];
__block id <SRRequest> request = nil;

__block SREventSourceStreamReader *eventSource;

[self.httpClient getAsync:url requestPreparer:^(id<SRRequest> req) {
request = req;
[connection prepareRequest:request];
Expand Down Expand Up @@ -114,7 +115,7 @@ - (void)openConnection:(SRConnection *)connection data:(NSString *)data initiali
}
}
} else {
SREventSourceStreamReader *eventSource = [[SREventSourceStreamReader alloc] initWithStream:response.stream];
eventSource = [[SREventSourceStreamReader alloc] initWithStream:response.stream];
__weak __typeof(&*self)weakSelf = self;
__weak __typeof(&*connection)weakConnection = connection;
__weak __typeof(&*response)weakResponse = response;
Expand All @@ -130,10 +131,7 @@ - (void)openConnection:(SRConnection *)connection data:(NSString *)data initiali
retry = false;
es.Close();
}, eventSource);*/

//TODO: Remove, this is only here because without it eventSource is released early
(connection.items)[@"retainEventSource"] = eventSource;


eventSource.opened = ^() {
__strong __typeof(&*weakConnection)strongConnection = weakConnection;
__strong __typeof(&*weakCallbackInvoker)strongCallbackInvoker = weakCallbackInvoker;
Expand Down

0 comments on commit b59a67b

Please sign in to comment.