From e03ab3d74aa4c99412f0f4dde1d7abc963bf5fc5 Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Thu, 23 Jan 2014 08:59:35 -0500 Subject: [PATCH 1/7] Fixes web sockets send function name mismatch --- SignalR.Client/Transports/SRAutoTransport.m | 4 ++-- SignalR.Client/Transports/SRWebSocketTransport.m | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SignalR.Client/Transports/SRAutoTransport.m b/SignalR.Client/Transports/SRAutoTransport.m index bec5fa93..ef00fed2 100644 --- a/SignalR.Client/Transports/SRAutoTransport.m +++ b/SignalR.Client/Transports/SRAutoTransport.m @@ -40,8 +40,8 @@ @interface SRAutoTransport () @implementation SRAutoTransport - (instancetype)init { - NSArray *transports = @[//[[SRWebSocketTransport alloc] init], - //[[SRServerSentEventsTransport alloc] init], + NSArray *transports = @[[[SRWebSocketTransport alloc] init], + [[SRServerSentEventsTransport alloc] init], [[SRLongPollingTransport alloc] init]]; return [self initWithTransports:[NSMutableArray arrayWithArray:transports]]; } diff --git a/SignalR.Client/Transports/SRWebSocketTransport.m b/SignalR.Client/Transports/SRWebSocketTransport.m index ef89eb17..1aa463e9 100644 --- a/SignalR.Client/Transports/SRWebSocketTransport.m +++ b/SignalR.Client/Transports/SRWebSocketTransport.m @@ -57,7 +57,7 @@ - (BOOL)supportsKeepAlive { return YES; } -- (void)negotiate:(id)connection connectionData:(NSString *)connectionData completionHandler:(void (^)(SRNegotiationResponse * response, NSError *error))block { +- (void)negotiate:(id)connection connectionData:(NSString *)connectionData completionHandler:(void (^)(SRNegotiationResponse *response, NSError *error))block { [super negotiate:connection connectionData:connectionData completionHandler:block]; } @@ -66,7 +66,7 @@ - (void)start:(id)connection connectionData:(NSString *)c [self performConnect:block]; } -- (void)send:(id )connection data:(NSString *)data completionHandler:(void (^)(id response, NSError *error))block { +- (void)send:(id)connection data:(NSString *)data connectionData:(NSString *)connectionData completionHandler:(void (^)(id response, NSError *error))block { [_webSocket send:data]; if(block) { @@ -74,13 +74,13 @@ - (void)send:(id )connection data:(NSString *)data comple } } -- (void)lostConnection:(id)connection { +- (void)abort:(id )connection timeout:(NSNumber *)timeout { [_webSocket close]; [_webSocket setDelegate:nil]; _webSocket = nil; } -- (void)abort:(id )connection timeout:(NSNumber *)timeout { +- (void)lostConnection:(id)connection { [_webSocket close]; [_webSocket setDelegate:nil]; _webSocket = nil; From 1bdeba04961d0a6d091dfa124d2eb14a52a112b2 Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Thu, 23 Jan 2014 10:20:31 -0500 Subject: [PATCH 2/7] Cleanup Hubs Implementation Convert Unit Testing to XCTest Adds OCMock for unit testing Fixes Exception when Websockets transport is closed --- Podfile | 5 + Podfile.lock | 11 +- .../project.pbxproj | 126 ++++++++++-------- .../SignalR.Client.Tests/SRChunkBufferTests.m | 22 +-- .../SignalR.Client.Tests/SRConnectionTests.m | 4 +- .../SRHubConnectionTests.m | 4 +- .../SignalR.Client.Tests/SRHubProxyTests.m | 33 ++++- .../SignalR.Client.Tests/SRJSONTests.m | 12 +- .../Controllers/ChatViewController.m | 4 +- SignalR.Client/Hubs/SRHubConnection.m | 2 +- SignalR.Client/Hubs/SRHubProxy.h | 2 + SignalR.Client/Hubs/SRHubProxy.m | 65 +++++---- SignalR.Client/Hubs/SRHubProxyExtensions.h | 58 -------- SignalR.Client/Hubs/SRHubProxyExtensions.m | 57 -------- SignalR.Client/Hubs/SRHubProxyInterface.h | 30 ++--- SignalR.Client/Hubs/SRHubResult.h | 7 + SignalR.Client/Hubs/SRHubResult.m | 4 + SignalR.Client/Hubs/SRHubs.h | 2 - SignalR.Client/Hubs/SRHubservable.h | 90 ------------- SignalR.Client/Hubs/SRHubservable.m | 59 -------- .../Transports/SRWebSocketTransport.m | 4 +- 21 files changed, 198 insertions(+), 403 deletions(-) delete mode 100644 SignalR.Client/Hubs/SRHubProxyExtensions.h delete mode 100644 SignalR.Client/Hubs/SRHubProxyExtensions.m delete mode 100644 SignalR.Client/Hubs/SRHubservable.h delete mode 100644 SignalR.Client/Hubs/SRHubservable.m diff --git a/Podfile b/Podfile index 37007c90..5fb732ba 100644 --- a/Podfile +++ b/Podfile @@ -11,4 +11,9 @@ target :"SignalR.Client.OSX", :exclusive => true do platform :osx, '10.8' pod 'AFNetworking', '2.0.2' pod 'SocketRocket', '0.3.1-beta2' +end + +target :"SignalR.Client.Tests.OSX", :exclusive => true do + platform :osx, '10.8' + pod 'OCMock' end \ No newline at end of file diff --git a/Podfile.lock b/Podfile.lock index a562278c..9e3b85c4 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -11,22 +11,23 @@ PODS: - AFNetworking/Security - AFNetworking/Serialization - AFNetworking/NSURLSession (2.0.2): - - AFNetworking/Reachability - - AFNetworking/Security - - AFNetworking/Serialization + - AFNetworking/NSURLConnection - AFNetworking/Reachability (2.0.2) - AFNetworking/Security (2.0.2) - AFNetworking/Serialization (2.0.2) - AFNetworking/UIKit (2.0.2): - AFNetworking/NSURLConnection + - OCMock (2.2.2) - SocketRocket (0.3.1-beta2) DEPENDENCIES: - AFNetworking (= 2.0.2) + - OCMock - SocketRocket (= 0.3.1-beta2) SPEC CHECKSUMS: - AFNetworking: 22de50ae71ab1c4859773f61068d6fcd1d8f9a4d + AFNetworking: e663917201cdb73f4ad2ba239ad35be8dc9a1e3c + OCMock: ffba68873fd32cfd35d885bddad23bfa816da4a3 SocketRocket: 7ac946bcce46287a791dfff3c1f8daa692821dae -COCOAPODS: 0.26.2 +COCOAPODS: 0.29.0 diff --git a/SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj b/SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj index 8928bd21..d8da9a2e 100644 --- a/SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj +++ b/SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj @@ -21,6 +21,7 @@ /* End PBXAggregateTarget section */ /* Begin PBXBuildFile section */ + 1E3243AF7B5746B28A85BC89 /* libPods-SignalR.Client.Tests.OSX.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 09893F87C8C94DFD96B7E8EC /* libPods-SignalR.Client.Tests.OSX.a */; }; 2E4277C4EA3C491FA03E1175 /* libPods-SignalR.Client.OSX.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2526AA83173A4BCF8707E847 /* libPods-SignalR.Client.OSX.a */; }; 3903084C173C660E00FE660E /* SRHeartbeatMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 3903084A173C660E00FE660E /* SRHeartbeatMonitor.h */; }; 3903084D173C660E00FE660E /* SRHeartbeatMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 3903084A173C660E00FE660E /* SRHeartbeatMonitor.h */; }; @@ -35,10 +36,8 @@ 3919638015AF222E00DDC946 /* SRHubConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782715AF13F6009B959E /* SRHubConnection.m */; }; 3919638115AF222E00DDC946 /* SRHubInvocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782915AF13F6009B959E /* SRHubInvocation.m */; }; 3919638215AF222E00DDC946 /* SRHubProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782B15AF13F6009B959E /* SRHubProxy.m */; }; - 3919638315AF222E00DDC946 /* SRHubProxyExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782D15AF13F6009B959E /* SRHubProxyExtensions.m */; }; 3919638415AF222E00DDC946 /* SRHubRegistrationData.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782F15AF13F6009B959E /* SRHubRegistrationData.m */; }; 3919638515AF222E00DDC946 /* SRHubResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920783115AF13F6009B959E /* SRHubResult.m */; }; - 3919638615AF222E00DDC946 /* SRHubservable.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920783415AF13F6009B959E /* SRHubservable.m */; }; 3919638715AF222E00DDC946 /* SRSubscription.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920783615AF13F6009B959E /* SRSubscription.m */; }; 3919638915AF223A00DDC946 /* NSObject+SRJSON.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920783B15AF13F6009B959E /* NSObject+SRJSON.m */; }; 3919638C15AF223A00DDC946 /* SRExceptionHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920784215AF13F6009B959E /* SRExceptionHelper.m */; }; @@ -54,11 +53,9 @@ 391963B515AF22FF00DDC946 /* SRHubConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920782615AF13F6009B959E /* SRHubConnection.h */; settings = {ATTRIBUTES = (Public, ); }; }; 391963B615AF22FF00DDC946 /* SRHubInvocation.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920782815AF13F6009B959E /* SRHubInvocation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 391963B715AF22FF00DDC946 /* SRHubProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920782A15AF13F6009B959E /* SRHubProxy.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 391963B815AF22FF00DDC946 /* SRHubProxyExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920782C15AF13F6009B959E /* SRHubProxyExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; }; 391963B915AF22FF00DDC946 /* SRHubRegistrationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920782E15AF13F6009B959E /* SRHubRegistrationData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 391963BA15AF22FF00DDC946 /* SRHubResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783015AF13F6009B959E /* SRHubResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; 391963BB15AF22FF00DDC946 /* SRHubs.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783215AF13F6009B959E /* SRHubs.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 391963BC15AF22FF00DDC946 /* SRHubservable.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783315AF13F6009B959E /* SRHubservable.h */; settings = {ATTRIBUTES = (Public, ); }; }; 391963BD15AF22FF00DDC946 /* SRSubscription.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783515AF13F6009B959E /* SRSubscription.h */; settings = {ATTRIBUTES = (Public, ); }; }; 391963BF15AF22FF00DDC946 /* NSObject+SRJSON.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783A15AF13F6009B959E /* NSObject+SRJSON.h */; settings = {ATTRIBUTES = (Private, ); }; }; 391963C215AF22FF00DDC946 /* SRDeserializable.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920784015AF13F6009B959E /* SRDeserializable.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -86,15 +83,11 @@ 3920787115AF13F6009B959E /* SRHubInvocation.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782915AF13F6009B959E /* SRHubInvocation.m */; }; 3920787215AF13F6009B959E /* SRHubProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920782A15AF13F6009B959E /* SRHubProxy.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3920787315AF13F6009B959E /* SRHubProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782B15AF13F6009B959E /* SRHubProxy.m */; }; - 3920787415AF13F6009B959E /* SRHubProxyExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920782C15AF13F6009B959E /* SRHubProxyExtensions.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 3920787515AF13F6009B959E /* SRHubProxyExtensions.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782D15AF13F6009B959E /* SRHubProxyExtensions.m */; }; 3920787615AF13F6009B959E /* SRHubRegistrationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920782E15AF13F6009B959E /* SRHubRegistrationData.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3920787715AF13F6009B959E /* SRHubRegistrationData.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920782F15AF13F6009B959E /* SRHubRegistrationData.m */; }; 3920787815AF13F6009B959E /* SRHubResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783015AF13F6009B959E /* SRHubResult.h */; settings = {ATTRIBUTES = (Private, ); }; }; 3920787915AF13F6009B959E /* SRHubResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920783115AF13F6009B959E /* SRHubResult.m */; }; 3920787A15AF13F6009B959E /* SRHubs.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783215AF13F6009B959E /* SRHubs.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 3920787B15AF13F6009B959E /* SRHubservable.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783315AF13F6009B959E /* SRHubservable.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 3920787C15AF13F6009B959E /* SRHubservable.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920783415AF13F6009B959E /* SRHubservable.m */; }; 3920787D15AF13F6009B959E /* SRSubscription.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783515AF13F6009B959E /* SRSubscription.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3920787E15AF13F6009B959E /* SRSubscription.m in Sources */ = {isa = PBXBuildFile; fileRef = 3920783615AF13F6009B959E /* SRSubscription.m */; }; 3920788115AF13F6009B959E /* NSObject+SRJSON.h in Headers */ = {isa = PBXBuildFile; fileRef = 3920783A15AF13F6009B959E /* NSObject+SRJSON.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -175,13 +168,10 @@ 39BB8D7715CAA576007B7245 /* SRHubConnectionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 39BB8D7515CAA576007B7245 /* SRHubConnectionTests.m */; }; 39BB8D7915CAA59C007B7245 /* libSignalR.Client.iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3920780715AF13C3009B959E /* libSignalR.Client.iOS.a */; }; 39BB8D7A15CAA5A2007B7245 /* libSignalR.Client.OSX.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3919636E15AF205300DDC946 /* libSignalR.Client.OSX.a */; }; - 39C97CEF15D3DDD600F66B50 /* SRHubProxyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 39C97CEE15D3DDD600F66B50 /* SRHubProxyTests.m */; }; 39C97CF015D3DDD600F66B50 /* SRHubProxyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 39C97CEE15D3DDD600F66B50 /* SRHubProxyTests.m */; }; 39E6FCE215C6BDC600434098 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 39E6FCE015C6BDC600434098 /* InfoPlist.strings */; }; - 39E6FCEC15C6BE4D00434098 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39E6FCEB15C6BE4D00434098 /* SenTestingKit.framework */; }; 39E6FCEE15C6BE5400434098 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39E6FCED15C6BE5400434098 /* Cocoa.framework */; }; 39E6FCEF15C6BE6800434098 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39E6FCED15C6BE5400434098 /* Cocoa.framework */; }; - 39E6FD1815C6BF4000434098 /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39E6FCEB15C6BE4D00434098 /* SenTestingKit.framework */; }; 39E6FD1915C6BF4000434098 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3920792015AF1853009B959E /* UIKit.framework */; }; 39E6FD1A15C6BF4000434098 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3920780A15AF13C3009B959E /* Foundation.framework */; }; 39E6FD2015C6BF4000434098 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 39E6FD1E15C6BF4000434098 /* InfoPlist.strings */; }; @@ -203,12 +193,16 @@ 39F7D7B11833FC99002590A6 /* SRServerSentEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 39F7D7AE1833FC99002590A6 /* SRServerSentEvent.h */; }; 39F7D7B21833FC99002590A6 /* SRServerSentEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 39F7D7AF1833FC99002590A6 /* SRServerSentEvent.m */; }; 39F7D7B31833FC99002590A6 /* SRServerSentEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 39F7D7AF1833FC99002590A6 /* SRServerSentEvent.m */; }; + 39FA64291891654500C035DC /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39FA64281891654500C035DC /* XCTest.framework */; }; + 39FA642A1891655300C035DC /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 39FA64281891654500C035DC /* XCTest.framework */; }; D27CBDC3D95B4241B1B76237 /* libPods-SignalR.Client.iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = F9E09B8C504C4E1BBE289746 /* libPods-SignalR.Client.iOS.a */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 036198E3EF3A4AB9A00C08B9 /* Pods-SignalR.Client.iOS.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalR.Client.iOS.xcconfig"; path = "../Pods/Pods-SignalR.Client.iOS.xcconfig"; sourceTree = SOURCE_ROOT; }; + 09893F87C8C94DFD96B7E8EC /* libPods-SignalR.Client.Tests.OSX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SignalR.Client.Tests.OSX.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 2526AA83173A4BCF8707E847 /* libPods-SignalR.Client.OSX.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SignalR.Client.OSX.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 28CD7529FF074ADAAD285BB4 /* Pods-SignalR.Client.Tests.OSX.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalR.Client.Tests.OSX.xcconfig"; path = "../Pods/Pods-SignalR.Client.Tests.OSX.xcconfig"; sourceTree = ""; }; 3903084A173C660E00FE660E /* SRHeartbeatMonitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRHeartbeatMonitor.h; sourceTree = ""; }; 3903084B173C660E00FE660E /* SRHeartbeatMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRHeartbeatMonitor.m; sourceTree = ""; }; 3919634415AF1EC100DDC946 /* SignalR.Samples.OSX.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SignalR.Samples.OSX.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -233,15 +227,11 @@ 3920782915AF13F6009B959E /* SRHubInvocation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRHubInvocation.m; sourceTree = ""; }; 3920782A15AF13F6009B959E /* SRHubProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRHubProxy.h; sourceTree = ""; }; 3920782B15AF13F6009B959E /* SRHubProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRHubProxy.m; sourceTree = ""; }; - 3920782C15AF13F6009B959E /* SRHubProxyExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRHubProxyExtensions.h; sourceTree = ""; }; - 3920782D15AF13F6009B959E /* SRHubProxyExtensions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRHubProxyExtensions.m; sourceTree = ""; }; 3920782E15AF13F6009B959E /* SRHubRegistrationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRHubRegistrationData.h; sourceTree = ""; }; 3920782F15AF13F6009B959E /* SRHubRegistrationData.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRHubRegistrationData.m; sourceTree = ""; }; 3920783015AF13F6009B959E /* SRHubResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRHubResult.h; sourceTree = ""; }; 3920783115AF13F6009B959E /* SRHubResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRHubResult.m; sourceTree = ""; }; 3920783215AF13F6009B959E /* SRHubs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRHubs.h; sourceTree = ""; }; - 3920783315AF13F6009B959E /* SRHubservable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRHubservable.h; sourceTree = ""; }; - 3920783415AF13F6009B959E /* SRHubservable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRHubservable.m; sourceTree = ""; }; 3920783515AF13F6009B959E /* SRSubscription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRSubscription.h; sourceTree = ""; }; 3920783615AF13F6009B959E /* SRSubscription.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRSubscription.m; sourceTree = ""; }; 3920783A15AF13F6009B959E /* NSObject+SRJSON.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+SRJSON.h"; sourceTree = ""; }; @@ -315,13 +305,12 @@ 39AF0D811713935A00E13E6E /* SRWebSocketConnectionInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SRWebSocketConnectionInfo.m; path = WebSockets/SRWebSocketConnectionInfo.m; sourceTree = ""; }; 39BB8D7515CAA576007B7245 /* SRHubConnectionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SRHubConnectionTests.m; path = SignalR.Client.Tests/SRHubConnectionTests.m; sourceTree = ""; }; 39C97CEE15D3DDD600F66B50 /* SRHubProxyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SRHubProxyTests.m; path = SignalR.Client.Tests/SRHubProxyTests.m; sourceTree = ""; }; - 39E6FCD515C6BDC600434098 /* SignalR.Client.Tests.OSX.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SignalR.Client.Tests.OSX.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 39E6FCD515C6BDC600434098 /* SignalR.Client.Tests.OSX.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SignalR.Client.Tests.OSX.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39E6FCDF15C6BDC600434098 /* SignalR.Client.Tests.OSX-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SignalR.Client.Tests.OSX-Info.plist"; sourceTree = ""; }; 39E6FCE115C6BDC600434098 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 39E6FCE615C6BDC600434098 /* SignalR.Client.Tests.OSX-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SignalR.Client.Tests.OSX-Prefix.pch"; sourceTree = ""; }; - 39E6FCEB15C6BE4D00434098 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 39E6FCED15C6BE5400434098 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Cocoa.framework; sourceTree = DEVELOPER_DIR; }; - 39E6FD1715C6BF4000434098 /* SignalR.Client.Tests.iOS.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SignalR.Client.Tests.iOS.octest; sourceTree = BUILT_PRODUCTS_DIR; }; + 39E6FD1715C6BF4000434098 /* SignalR.Client.Tests.iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SignalR.Client.Tests.iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 39E6FD1D15C6BF4000434098 /* SignalR.Client.Tests.iOS-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SignalR.Client.Tests.iOS-Info.plist"; sourceTree = ""; }; 39E6FD1F15C6BF4000434098 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 39E6FD2415C6BF4000434098 /* SignalR.Client.Tests.iOS-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SignalR.Client.Tests.iOS-Prefix.pch"; sourceTree = ""; }; @@ -340,6 +329,7 @@ 39EBAC4016D07D5100C6F359 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = text; name = README.md; path = ../README.md; sourceTree = ""; }; 39F7D7AE1833FC99002590A6 /* SRServerSentEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SRServerSentEvent.h; sourceTree = ""; }; 39F7D7AF1833FC99002590A6 /* SRServerSentEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SRServerSentEvent.m; sourceTree = ""; }; + 39FA64281891654500C035DC /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 8CFF876916E13FF500B67FCA /* SRHubConnectionInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SRHubConnectionInterface.h; sourceTree = ""; }; E1168910CBED44F49353CF85 /* Pods-SignalR.Client.OSX.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SignalR.Client.OSX.xcconfig"; path = "../Pods/Pods-SignalR.Client.OSX.xcconfig"; sourceTree = SOURCE_ROOT; }; F9E09B8C504C4E1BBE289746 /* libPods-SignalR.Client.iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SignalR.Client.iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -397,9 +387,10 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 39FA642A1891655300C035DC /* XCTest.framework in Frameworks */, 39BB8D7A15CAA5A2007B7245 /* libSignalR.Client.OSX.a in Frameworks */, 39E6FCEE15C6BE5400434098 /* Cocoa.framework in Frameworks */, - 39E6FCEC15C6BE4D00434098 /* SenTestingKit.framework in Frameworks */, + 1E3243AF7B5746B28A85BC89 /* libPods-SignalR.Client.Tests.OSX.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -407,8 +398,8 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + 39FA64291891654500C035DC /* XCTest.framework in Frameworks */, 39BB8D7915CAA59C007B7245 /* libSignalR.Client.iOS.a in Frameworks */, - 39E6FD1815C6BF4000434098 /* SenTestingKit.framework in Frameworks */, 39E6FD1915C6BF4000434098 /* UIKit.framework in Frameworks */, 39E6FD1A15C6BF4000434098 /* Foundation.framework in Frameworks */, ); @@ -488,6 +479,7 @@ 3920780815AF13C3009B959E /* Products */, 036198E3EF3A4AB9A00C08B9 /* Pods-SignalR.Client.iOS.xcconfig */, E1168910CBED44F49353CF85 /* Pods-SignalR.Client.OSX.xcconfig */, + 28CD7529FF074ADAAD285BB4 /* Pods-SignalR.Client.Tests.OSX.xcconfig */, ); sourceTree = ""; }; @@ -498,8 +490,8 @@ 3920791E15AF1853009B959E /* SignalR.Samples.iOS.app */, 3919634415AF1EC100DDC946 /* SignalR.Samples.OSX.app */, 3919636E15AF205300DDC946 /* libSignalR.Client.OSX.a */, - 39E6FCD515C6BDC600434098 /* SignalR.Client.Tests.OSX.octest */, - 39E6FD1715C6BF4000434098 /* SignalR.Client.Tests.iOS.octest */, + 39E6FCD515C6BDC600434098 /* SignalR.Client.Tests.OSX.xctest */, + 39E6FD1715C6BF4000434098 /* SignalR.Client.Tests.iOS.xctest */, ); name = Products; sourceTree = ""; @@ -507,6 +499,7 @@ 3920780915AF13C3009B959E /* Frameworks */ = { isa = PBXGroup; children = ( + 39FA64281891654500C035DC /* XCTest.framework */, 397612B817FDFAA300C02327 /* CoreServices.framework */, 3994AAAE1714D08E00E452F7 /* libicucore.dylib */, 3994AAAA1714D06900E452F7 /* Security.framework */, @@ -515,11 +508,11 @@ 396D2866165ABE4F0000D19E /* SystemConfiguration.framework */, 39E7A5DA15E532380097F395 /* CoreGraphics.framework */, 39E6FCED15C6BE5400434098 /* Cocoa.framework */, - 39E6FCEB15C6BE4D00434098 /* SenTestingKit.framework */, 3920780A15AF13C3009B959E /* Foundation.framework */, 3920792015AF1853009B959E /* UIKit.framework */, F9E09B8C504C4E1BBE289746 /* libPods-SignalR.Client.iOS.a */, 2526AA83173A4BCF8707E847 /* libPods-SignalR.Client.OSX.a */, + 09893F87C8C94DFD96B7E8EC /* libPods-SignalR.Client.Tests.OSX.a */, ); name = Frameworks; sourceTree = ""; @@ -576,16 +569,12 @@ 39EBAC2E16D067CB00C6F359 /* SRHubProxyInterface.h */, 3920782A15AF13F6009B959E /* SRHubProxy.h */, 3920782B15AF13F6009B959E /* SRHubProxy.m */, - 3920782C15AF13F6009B959E /* SRHubProxyExtensions.h */, - 3920782D15AF13F6009B959E /* SRHubProxyExtensions.m */, 3920782815AF13F6009B959E /* SRHubInvocation.h */, 3920782915AF13F6009B959E /* SRHubInvocation.m */, 3920782E15AF13F6009B959E /* SRHubRegistrationData.h */, 3920782F15AF13F6009B959E /* SRHubRegistrationData.m */, 3920783015AF13F6009B959E /* SRHubResult.h */, 3920783115AF13F6009B959E /* SRHubResult.m */, - 3920783315AF13F6009B959E /* SRHubservable.h */, - 3920783415AF13F6009B959E /* SRHubservable.m */, 3920783515AF13F6009B959E /* SRSubscription.h */, 3920783615AF13F6009B959E /* SRSubscription.m */, ); @@ -762,11 +751,9 @@ 391963B515AF22FF00DDC946 /* SRHubConnection.h in Headers */, 391963B615AF22FF00DDC946 /* SRHubInvocation.h in Headers */, 391963B715AF22FF00DDC946 /* SRHubProxy.h in Headers */, - 391963B815AF22FF00DDC946 /* SRHubProxyExtensions.h in Headers */, 391963B915AF22FF00DDC946 /* SRHubRegistrationData.h in Headers */, 391963BA15AF22FF00DDC946 /* SRHubResult.h in Headers */, 391963BB15AF22FF00DDC946 /* SRHubs.h in Headers */, - 391963BC15AF22FF00DDC946 /* SRHubservable.h in Headers */, 391963BD15AF22FF00DDC946 /* SRSubscription.h in Headers */, 39F7D7B11833FC99002590A6 /* SRServerSentEvent.h in Headers */, 391963C415AF22FF00DDC946 /* SRSerializable.h in Headers */, @@ -806,10 +793,8 @@ 3920786E15AF13F6009B959E /* SRHubConnection.h in Headers */, 3920787015AF13F6009B959E /* SRHubInvocation.h in Headers */, 3920787215AF13F6009B959E /* SRHubProxy.h in Headers */, - 3920787415AF13F6009B959E /* SRHubProxyExtensions.h in Headers */, 3920787615AF13F6009B959E /* SRHubRegistrationData.h in Headers */, 3920787815AF13F6009B959E /* SRHubResult.h in Headers */, - 3920787B15AF13F6009B959E /* SRHubservable.h in Headers */, 39F7D7B01833FC99002590A6 /* SRServerSentEvent.h in Headers */, 3920787D15AF13F6009B959E /* SRSubscription.h in Headers */, 3920788715AF13F6009B959E /* SRDeserializable.h in Headers */, @@ -916,10 +901,12 @@ isa = PBXNativeTarget; buildConfigurationList = 39E6FCE915C6BDC600434098 /* Build configuration list for PBXNativeTarget "SignalR.Client.Tests.OSX" */; buildPhases = ( + F4D7BEBC9AD74031A7814F3F /* Check Pods Manifest.lock */, 39E6FCD015C6BDC600434098 /* Sources */, 39E6FCD115C6BDC600434098 /* Frameworks */, 39E6FCD215C6BDC600434098 /* Resources */, 39E6FCD315C6BDC600434098 /* ShellScript */, + 2757A39FF3A7450F845911C0 /* Copy Pods Resources */, ); buildRules = ( ); @@ -927,8 +914,8 @@ ); name = SignalR.Client.Tests.OSX; productName = SignalR.Client.Tests.OSX; - productReference = 39E6FCD515C6BDC600434098 /* SignalR.Client.Tests.OSX.octest */; - productType = "com.apple.product-type.bundle"; + productReference = 39E6FCD515C6BDC600434098 /* SignalR.Client.Tests.OSX.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; }; 39E6FD1615C6BF4000434098 /* SignalR.Client.Tests.iOS */ = { isa = PBXNativeTarget; @@ -945,8 +932,8 @@ ); name = SignalR.Client.Tests.iOS; productName = SignalR.Client.Tests.iOS; - productReference = 39E6FD1715C6BF4000434098 /* SignalR.Client.Tests.iOS.octest */; - productType = "com.apple.product-type.bundle"; + productReference = 39E6FD1715C6BF4000434098 /* SignalR.Client.Tests.iOS.xctest */; + productType = "com.apple.product-type.bundle.unit-test"; }; /* End PBXNativeTarget section */ @@ -1025,6 +1012,21 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ + 2757A39FF3A7450F845911C0 /* Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Copy Pods Resources"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/../Pods/Pods-SignalR.Client.Tests.OSX-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; 391963DE15AF25EC00DDC946 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -1092,6 +1094,21 @@ shellPath = /bin/sh; shellScript = "\"${SRCROOT}/../Pods/Pods-SignalR.Client.OSX-resources.sh\"\n"; }; + F4D7BEBC9AD74031A7814F3F /* Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Check Pods Manifest.lock"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -1112,11 +1129,9 @@ 3919638015AF222E00DDC946 /* SRHubConnection.m in Sources */, 3919638115AF222E00DDC946 /* SRHubInvocation.m in Sources */, 3919638215AF222E00DDC946 /* SRHubProxy.m in Sources */, - 3919638315AF222E00DDC946 /* SRHubProxyExtensions.m in Sources */, 39F7D7B31833FC99002590A6 /* SRServerSentEvent.m in Sources */, 3919638415AF222E00DDC946 /* SRHubRegistrationData.m in Sources */, 3919638515AF222E00DDC946 /* SRHubResult.m in Sources */, - 3919638615AF222E00DDC946 /* SRHubservable.m in Sources */, 3919638715AF222E00DDC946 /* SRSubscription.m in Sources */, 3919638915AF223A00DDC946 /* NSObject+SRJSON.m in Sources */, 3919638C15AF223A00DDC946 /* SRExceptionHelper.m in Sources */, @@ -1144,11 +1159,9 @@ 3920786F15AF13F6009B959E /* SRHubConnection.m in Sources */, 3920787115AF13F6009B959E /* SRHubInvocation.m in Sources */, 3920787315AF13F6009B959E /* SRHubProxy.m in Sources */, - 3920787515AF13F6009B959E /* SRHubProxyExtensions.m in Sources */, 39F7D7B21833FC99002590A6 /* SRServerSentEvent.m in Sources */, 3920787715AF13F6009B959E /* SRHubRegistrationData.m in Sources */, 3920787915AF13F6009B959E /* SRHubResult.m in Sources */, - 3920787C15AF13F6009B959E /* SRHubservable.m in Sources */, 3920787E15AF13F6009B959E /* SRSubscription.m in Sources */, 3920788215AF13F6009B959E /* NSObject+SRJSON.m in Sources */, 3920788915AF13F6009B959E /* SRExceptionHelper.m in Sources */, @@ -1207,7 +1220,6 @@ 39BB8D7615CAA576007B7245 /* SRHubConnectionTests.m in Sources */, 3940059415CC6A2C006673E2 /* SRChunkBufferTests.m in Sources */, 3940059915CC6DD6006673E2 /* SRConnectionTests.m in Sources */, - 39C97CEF15D3DDD600F66B50 /* SRHubProxyTests.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1522,14 +1534,17 @@ }; 39E6FCE715C6BDC600434098 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 28CD7529FF074ADAAD285BB4 /* Pods-SignalR.Client.Tests.OSX.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks\"", + "\\\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\\\"", + "\\\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks\\\"", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", ); GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -1538,13 +1553,13 @@ INFOPLIST_FILE = "SignalR.Client.Tests.OSX/SignalR.Client.Tests.OSX-Info.plist"; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx10.7; - WRAPPER_EXTENSION = octest; + SDKROOT = macosx; }; name = Debug; }; 39E6FCE815C6BDC600434098 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 28CD7529FF074ADAAD285BB4 /* Pods-SignalR.Client.Tests.OSX.xcconfig */; buildSettings = { ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -1552,8 +1567,10 @@ COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", - "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks\"", + "\\\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\\\"", + "\\\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/System/Library/Frameworks\\\"", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", ); GCC_ENABLE_OBJC_EXCEPTIONS = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES; @@ -1561,8 +1578,7 @@ GCC_WARN_64_TO_32_BIT_CONVERSION = YES; INFOPLIST_FILE = "SignalR.Client.Tests.OSX/SignalR.Client.Tests.OSX-Info.plist"; PRODUCT_NAME = "$(TARGET_NAME)"; - SDKROOT = macosx10.7; - WRAPPER_EXTENSION = octest; + SDKROOT = macosx; }; name = Release; }; @@ -1572,15 +1588,16 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + "\\\"$(SDKROOT)/Developer/Library/Frameworks\\\"", + "\\\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\\\"", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "SignalR.Client.Tests.iOS/SignalR.Client.Tests.iOS-Prefix.pch"; INFOPLIST_FILE = "SignalR.Client.Tests.iOS/SignalR.Client.Tests.iOS-Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 5.1; PRODUCT_NAME = "$(TARGET_NAME)"; - WRAPPER_EXTENSION = octest; }; name = Debug; }; @@ -1590,8 +1607,10 @@ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; FRAMEWORK_SEARCH_PATHS = ( - "\"$(SDKROOT)/Developer/Library/Frameworks\"", - "\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"", + "\\\"$(SDKROOT)/Developer/Library/Frameworks\\\"", + "\\\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\\\"", + "$(inherited)", + "$(DEVELOPER_FRAMEWORKS_DIR)", ); GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PREFIX_HEADER = "SignalR.Client.Tests.iOS/SignalR.Client.Tests.iOS-Prefix.pch"; @@ -1599,7 +1618,6 @@ IPHONEOS_DEPLOYMENT_TARGET = 5.1; PRODUCT_NAME = "$(TARGET_NAME)"; VALIDATE_PRODUCT = YES; - WRAPPER_EXTENSION = octest; }; name = Release; }; diff --git a/SignalR.Client.ObjC/SignalR.Client.Tests/SRChunkBufferTests.m b/SignalR.Client.ObjC/SignalR.Client.Tests/SRChunkBufferTests.m index 87f004a5..6bf02fa3 100644 --- a/SignalR.Client.ObjC/SignalR.Client.Tests/SRChunkBufferTests.m +++ b/SignalR.Client.ObjC/SignalR.Client.Tests/SRChunkBufferTests.m @@ -6,10 +6,10 @@ // Copyright (c) 2012 DyKnow LLC. All rights reserved. // -#import +#import #import "SRChunkBuffer.h" -@interface SRChunkBufferTests : SenTestCase +@interface SRChunkBufferTests : XCTestCase @end @@ -35,7 +35,7 @@ - (void)testReturnsNullIfNoNewLineIfBuffer [buffer add:data]; // Assert - STAssertNil([buffer readLine], @"Expected nil received object"); + XCTAssertNil([buffer readLine], @"Expected nil received object"); } - (void)testReturnsTextUpToNewLine @@ -48,7 +48,7 @@ - (void)testReturnsTextUpToNewLine [buffer add:data]; // Assert - STAssertTrue([[buffer readLine] isEqualToString:@"hello world"], @"Expected to read first line only"); + XCTAssertTrue([[buffer readLine] isEqualToString:@"hello world"], @"Expected to read first line only"); } - (void)testCanReadMultipleLines @@ -61,9 +61,9 @@ - (void)testCanReadMultipleLines [buffer add:data]; // Assert - STAssertTrue([[buffer readLine] isEqualToString:@"hel"], @"Expected to read first line"); - STAssertTrue([[buffer readLine] isEqualToString:@"lo world"], @"Expected to read second line"); - STAssertNil([buffer readLine], @"Expected nil received object"); + XCTAssertTrue([[buffer readLine] isEqualToString:@"hel"], @"Expected to read first line"); + XCTAssertTrue([[buffer readLine] isEqualToString:@"lo world"], @"Expected to read second line"); + XCTAssertNil([buffer readLine], @"Expected nil received object"); } - (void)testWillCompleteNewLin @@ -72,16 +72,16 @@ - (void)testWillCompleteNewLin SRChunkBuffer *buffer = [[SRChunkBuffer alloc] init]; NSData *data = [[NSString stringWithFormat:@"hello"] dataUsingEncoding:NSUTF8StringEncoding]; [buffer add:data]; - STAssertNil([buffer readLine], @"Expected nil received object"); + XCTAssertNil([buffer readLine], @"Expected nil received object"); data = [[NSString stringWithFormat:@"\n"] dataUsingEncoding:NSUTF8StringEncoding]; [buffer add:data]; - STAssertTrue([[buffer readLine] isEqualToString:@"hello"], @"Expected to read first line only"); + XCTAssertTrue([[buffer readLine] isEqualToString:@"hello"], @"Expected to read first line only"); data = [[NSString stringWithFormat:@"Another line"] dataUsingEncoding:NSUTF8StringEncoding]; [buffer add:data]; - STAssertNil([buffer readLine], @"Expected nil received object"); + XCTAssertNil([buffer readLine], @"Expected nil received object"); data = [[NSString stringWithFormat:@"\nnext"] dataUsingEncoding:NSUTF8StringEncoding]; [buffer add:data]; - STAssertTrue([[buffer readLine] isEqualToString:@"Another line"], @"Expected to read first line only"); + XCTAssertTrue([[buffer readLine] isEqualToString:@"Another line"], @"Expected to read first line only"); } @end diff --git a/SignalR.Client.ObjC/SignalR.Client.Tests/SRConnectionTests.m b/SignalR.Client.ObjC/SignalR.Client.Tests/SRConnectionTests.m index ab857dea..de998771 100644 --- a/SignalR.Client.ObjC/SignalR.Client.Tests/SRConnectionTests.m +++ b/SignalR.Client.ObjC/SignalR.Client.Tests/SRConnectionTests.m @@ -6,12 +6,12 @@ // Copyright (c) 2012 DyKnow LLC. All rights reserved. // -#import +#import #import "SRConnection.h" #import "SRVersion.h" -@interface SRConnectionTests : SenTestCase +@interface SRConnectionTests : XCTestCase @end diff --git a/SignalR.Client.ObjC/SignalR.Client.Tests/SRHubConnectionTests.m b/SignalR.Client.ObjC/SignalR.Client.Tests/SRHubConnectionTests.m index deefb109..5bdfba81 100644 --- a/SignalR.Client.ObjC/SignalR.Client.Tests/SRHubConnectionTests.m +++ b/SignalR.Client.ObjC/SignalR.Client.Tests/SRHubConnectionTests.m @@ -6,10 +6,10 @@ // Copyright (c) 2012 DyKnow LLC. All rights reserved. // -#import +#import #import "SignalR.h" -@interface SRHubConnectionTests : SenTestCase +@interface SRHubConnectionTests : XCTestCase @end diff --git a/SignalR.Client.ObjC/SignalR.Client.Tests/SRHubProxyTests.m b/SignalR.Client.ObjC/SignalR.Client.Tests/SRHubProxyTests.m index b323b47a..34de6154 100644 --- a/SignalR.Client.ObjC/SignalR.Client.Tests/SRHubProxyTests.m +++ b/SignalR.Client.ObjC/SignalR.Client.Tests/SRHubProxyTests.m @@ -6,11 +6,12 @@ // Copyright (c) 2012 DyKnow LLC. All rights reserved. // -#import +#import +#import #import "SignalR.h" //#import "NSDictionary+QueryString.h" -@interface SRHubProxyTests : SenTestCase +@interface SRHubProxyTests : XCTestCase @end @@ -26,6 +27,34 @@ - (void)tearDown [super tearDown]; } +#pragma mark - +#pragma mark Subscriptions + +- (void)testSubscribingToNothingThrows { + + id mockConnection = [OCMockObject mockForProtocol:@protocol(SRConnectionInterface)]; + id hub = [[SRHubProxy alloc] initWithConnection:mockConnection hubName:@"myHub"]; + @try { + [hub on:nil perform:nil selector:nil]; + XCTFail(@"Event Name must not be nil"); + } + @catch (NSException *exception) { + + } +} + +- (void)testSubscribingToEmptyStringThrows { + id mockConnection = [OCMockObject mockForProtocol:@protocol(SRConnectionInterface)]; + id hub = [[SRHubProxy alloc] initWithConnection:mockConnection hubName:@"myHub"]; + @try { + [hub on:@"" perform:nil selector:nil]; + XCTFail(@"Event Name must not be empty"); + } + @catch (NSException *exception) { + + } +} + /** * Test for adding support for custom query strings on hubs * SRHubConnection should allow for custom query strings diff --git a/SignalR.Client.ObjC/SignalR.Client.Tests/SRJSONTests.m b/SignalR.Client.ObjC/SignalR.Client.Tests/SRJSONTests.m index 6bb9bc1c..7e4e18e6 100644 --- a/SignalR.Client.ObjC/SignalR.Client.Tests/SRJSONTests.m +++ b/SignalR.Client.ObjC/SignalR.Client.Tests/SRJSONTests.m @@ -6,7 +6,7 @@ // Copyright (c) 2012 DyKnow LLC. All rights reserved. // -#import +#import #import "NSObject+SRJSON.h" #import "SRSerializable.h" @@ -33,7 +33,7 @@ - (id)proxyForJson -@interface SRJSONTests : SenTestCase +@interface SRJSONTests : XCTestCase @end @@ -57,7 +57,7 @@ - (void)tearDown - (void)testThrowWhenEnsureFoundationObjectShouldReturnNil { InvalidModel *model = [[InvalidModel alloc] init]; - STAssertThrowsSpecificNamed([model SRJSONRepresentation], NSException, NSInternalInconsistencyException, @"SRJSONRepresentation succeeded when it was expected to throw an exception") ; + XCTAssertThrowsSpecificNamed([model SRJSONRepresentation], NSException, NSInternalInconsistencyException, @"SRJSONRepresentation succeeded when it was expected to throw an exception") ; } /** @@ -68,7 +68,7 @@ - (void)testThrowWhenEnsureFoundationObjectShouldReturnNil - (void)testThrowWhenEnsureFoundationObjectShouldReturnNil_NSArray { NSArray *nonConformingArray = @[[[InvalidModel alloc] init]]; - STAssertThrowsSpecificNamed([nonConformingArray SRJSONRepresentation], NSException, NSInternalInconsistencyException, @"SRJSONRepresentation succeeded when it was expected to throw an exception") ; + XCTAssertThrowsSpecificNamed([nonConformingArray SRJSONRepresentation], NSException, NSInternalInconsistencyException, @"SRJSONRepresentation succeeded when it was expected to throw an exception") ; } /** @@ -79,7 +79,7 @@ - (void)testThrowWhenEnsureFoundationObjectShouldReturnNil_NSArray - (void)testThrowWhenEnsureFoundationObjectShouldReturnNil_NSDictionary { NSDictionary *nonConformingDictionary = @{@"somekey": [[InvalidModel alloc] init]}; - STAssertThrowsSpecificNamed([nonConformingDictionary SRJSONRepresentation], NSException, NSInternalInconsistencyException, @"SRJSONRepresentation succeeded when it was expected to throw an exception") ; + XCTAssertThrowsSpecificNamed([nonConformingDictionary SRJSONRepresentation], NSException, NSInternalInconsistencyException, @"SRJSONRepresentation succeeded when it was expected to throw an exception") ; } /** @@ -90,7 +90,7 @@ - (void)testThrowWhenEnsureFoundationObjectShouldReturnNil_NSDictionary - (void)testThrowWhenEnsureFoundationObjectShouldReturnNil_ConformingObjectReturnsNil { InvalidConformingModel *model = [[InvalidConformingModel alloc] init]; - STAssertThrowsSpecificNamed([model SRJSONRepresentation], NSException, NSInternalInconsistencyException, @"SRJSONRepresentation succeeded when it was expected to throw an exception") ; + XCTAssertThrowsSpecificNamed([model SRJSONRepresentation], NSException, NSInternalInconsistencyException, @"SRJSONRepresentation succeeded when it was expected to throw an exception") ; } @end diff --git a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ChatViewController.m b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ChatViewController.m index 6379f0b5..d5126633 100644 --- a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ChatViewController.m +++ b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ChatViewController.m @@ -113,8 +113,8 @@ - (IBAction)connectClicked:(id)sender connection = [SRHubConnection connectionWithURL:server]; hub = [connection createHubProxy:@"Chat"]; - [hub setMember:@"focus" object:@YES]; - [hub setMember:@"unread" object:@0]; + [[hub state] setValue:@YES forKey:@"focus"]; + [[hub state] setValue:0 forKey:@"unread"]; [hub on:@"refreshRoom" perform:self selector:@selector(refreshRoom:)]; [hub on:@"showRooms" perform:self selector:@selector(showRooms:)]; diff --git a/SignalR.Client/Hubs/SRHubConnection.m b/SignalR.Client/Hubs/SRHubConnection.m index b1b33a0a..c2ceb99b 100644 --- a/SignalR.Client/Hubs/SRHubConnection.m +++ b/SignalR.Client/Hubs/SRHubConnection.m @@ -167,7 +167,7 @@ - (void)didReceiveData:(id)data { if(hubProxy) { if(invocation.state != nil && ![invocation.state isKindOfClass:[NSNull class]]) { for (id key in invocation.state) { - [hubProxy setMember:key object:(invocation.state)[key]]; + [[hubProxy state] setValue:(invocation.state)[key] forKey:key]; } } [hubProxy invokeEvent:invocation.method withArgs:invocation.args]; diff --git a/SignalR.Client/Hubs/SRHubProxy.h b/SignalR.Client/Hubs/SRHubProxy.h index d9098e18..a2be733f 100644 --- a/SignalR.Client/Hubs/SRHubProxy.h +++ b/SignalR.Client/Hubs/SRHubProxy.h @@ -29,6 +29,8 @@ */ @interface SRHubProxy : NSObject +@property (strong, nonatomic, readonly) NSMutableDictionary *state; + ///------------------------------- /// @name Initializing an SRHubProxy Object ///------------------------------- diff --git a/SignalR.Client/Hubs/SRHubProxy.m b/SignalR.Client/Hubs/SRHubProxy.m index 729e9eb6..3cb624ff 100644 --- a/SignalR.Client/Hubs/SRHubProxy.m +++ b/SignalR.Client/Hubs/SRHubProxy.m @@ -32,7 +32,6 @@ @interface SRHubProxy () @property (assign, nonatomic, readonly) id connection; @property (strong, nonatomic, readonly) NSString *hubName; -@property (strong, nonatomic, readonly) NSMutableDictionary *state; @property (strong, nonatomic, readonly) NSMutableDictionary *subscriptions; @end @@ -53,16 +52,26 @@ - (instancetype)initWithConnection:(id )connection hub } #pragma mark - -#pragma mark Subscription Management +#pragma mark Subscribe -- (SRSubscription *)subscribe:(NSString *)eventName { +- (SRSubscription *)on:(NSString *)eventName perform:(NSObject *)object selector:(SEL)selector { if(eventName == nil || [eventName isEqualToString:@""]) { [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Argument eventName is null",@"NSInvalidArgumentException")]; } + if (object == nil) { + //TODO: Throw + } + + if (selector == nil) { + //TODO: Throw + } + SRSubscription *subscription = _subscriptions[eventName]; if(subscription == nil) { subscription = [[SRSubscription alloc] init]; + subscription.object = object; + subscription.selector = selector; _subscriptions[eventName] = subscription; } @@ -91,17 +100,8 @@ - (void)invokeEvent:(NSString *)eventName withArgs:(NSArray *)args { } } -#pragma mark - -#pragma mark State Management - -- (id)getMember:(NSString *)name { - id value = _state[name]; - return value; -} - -- (void)setMember:(NSString *)name object:(id)value { - [_state setValue:value forKey:name]; -} +#pragma mark - +#pragma mark Publish - (void)invoke:(NSString *)method withArgs:(NSArray *)args { [self invoke:method withArgs:args completionHandler:nil]; @@ -116,26 +116,35 @@ - (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(vo [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Argument args is null",@"NSInvalidArgumentException")]; } - NSString *callbackId = [_connection registerCallback:^(SRHubResult *hubResult) { - if (hubResult != nil) { - if(![hubResult.error isKindOfClass:[NSNull class]] && hubResult.error != nil) { + NSString *callbackId = [_connection registerCallback:^(SRHubResult *result) { + if (result != nil) { + if(result.error != nil && ![result.error isKindOfClass:[NSNull class]]) { NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; userInfo[NSLocalizedFailureReasonErrorKey] = NSInternalInconsistencyException; - userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"%@",hubResult.error]; + userInfo[NSLocalizedDescriptionKey] = [NSString stringWithFormat:@"%@", result.error]; NSError *error = [NSError errorWithDomain:[NSString stringWithFormat:NSLocalizedString(@"com.SignalR-ObjC.%@",@""),NSStringFromClass([self class])] code:0 userInfo:userInfo]; [_connection didReceiveError:error]; - } - - if(![hubResult.state isKindOfClass:[NSNull class]] && hubResult.state != nil) { - for (id key in hubResult.state) { - [self setMember:key object:(hubResult.state)[key]]; + if (block != nil) { + block(error); + } + } else { + if(result.state != nil && ![result.state isKindOfClass:[NSNull class]]) { + for (id key in result.state) { + [self.state setValue:(result.state)[key] forKey:key]; + } + } + + if(result.result != nil && ![result.result isKindOfClass:[NSNull class]]) { + if (block != nil) { + block(result.result); + } + } else { + if (block != nil) { + block(@{}); + } } - } - - if (block != nil) { - block(hubResult.result); } } }]; @@ -146,7 +155,7 @@ - (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(vo hubData.args = [NSMutableArray arrayWithArray:args]; hubData.callbackId = callbackId; - if (_state.count > 0) { + if ([[_state allKeys] count] > 0) { hubData.state = _state; } diff --git a/SignalR.Client/Hubs/SRHubProxyExtensions.h b/SignalR.Client/Hubs/SRHubProxyExtensions.h deleted file mode 100644 index d598073a..00000000 --- a/SignalR.Client/Hubs/SRHubProxyExtensions.h +++ /dev/null @@ -1,58 +0,0 @@ -// -// SRHubProxyExtensions.h -// SignalR -// -// Created by Alex Billingsley on 11/10/11. -// Copyright (c) 2011 DyKnow LLC. (http://dyknow.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -// to permit persons to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of -// the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - -#import -#import "SRHubProxy.h" - -@class SRHubservable; -@class SRSubscription; - -@interface SRHubProxy (Extensions) - -/** - * An extension method for accessing objects contained in the `SRHubProxy` state dictionary - * - * @param name the key for which to return the corresponding value. - * - * @return Returns the value associated with a given key. - */ -- (id)getValue:(NSString *)name; - -/** - * Creates a new `SRSubscription` object - * - * @param eventName the name of the event to subscribe to - * @param object The receiver to perform selector on - * @param selector A selector identifying the message to send. - * @return An instance of an `SRSubscription` object - */ -- (SRSubscription *)on:(NSString *)eventName perform:(NSObject *)object selector:(SEL)selector; - -/** - * Initalizes an `SRHubservable` with the specified eventName - * - * @param eventName the `NSString` object representing the name of the subscription event - * @return an `SRHubservable` object - */ -- (SRHubservable *)observe:(NSString *)eventName; - -@end diff --git a/SignalR.Client/Hubs/SRHubProxyExtensions.m b/SignalR.Client/Hubs/SRHubProxyExtensions.m deleted file mode 100644 index 7a195c8c..00000000 --- a/SignalR.Client/Hubs/SRHubProxyExtensions.m +++ /dev/null @@ -1,57 +0,0 @@ -// -// SRHubProxyExtensions.m -// SignalR -// -// Created by Alex Billingsley on 11/10/11. -// Copyright (c) 2011 DyKnow LLC. (http://dyknow.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -// to permit persons to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of -// the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - -#import "SRHubProxyExtensions.h" -#import "SRHubservable.h" -#import "SRSubscription.h" - -@implementation SRHubProxy (Extensions) - -- (id)getValue:(NSString *)name -{ - id value = [self getMember:name]; - return value; -} - -- (SRSubscription *)on:(NSString *)eventName perform:(NSObject *)object selector:(SEL)selector -{ - if (eventName == nil || [eventName isEqualToString:@""]) { - //TODO: Throw - } - - if (selector == nil) { - //TODO: Throw - } - - SRSubscription *subscription = [self subscribe:eventName]; - subscription.object = object; - subscription.selector = selector; - - return subscription; -} - -- (SRHubservable *)observe:(NSString *)eventName -{ - return [[SRHubservable alloc] initWithProxy:self eventName:eventName]; -} - -@end diff --git a/SignalR.Client/Hubs/SRHubProxyInterface.h b/SignalR.Client/Hubs/SRHubProxyInterface.h index 2d6518e8..2ed1bee0 100644 --- a/SignalR.Client/Hubs/SRHubProxyInterface.h +++ b/SignalR.Client/Hubs/SRHubProxyInterface.h @@ -27,38 +27,24 @@ @protocol SRHubProxyInterface ///------------------------------- -/// @name State Management +/// @name Subscribe ///------------------------------- /** - * Returns the object corresponding to name in the state dictionary + * Creates a new `SRSubscription` object * - * @param name the key for which to return the corresponding value. - * - * @return Returns the value associated with a given key. + * @param eventName the name of the event to subscribe to + * @param object The receiver to perform selector on + * @param selector A selector identifying the message to send. + * @return An instance of an `SRSubscription` object */ -- (id)getMember:(NSString *)name; +- (SRSubscription *)on:(NSString *)eventName perform:(NSObject *)object selector:(SEL)selector; -/** - * Adds a given key-value pair to the state dictionary. - * - * @param name The key for value - * @param value The value for key. - */ -- (void)setMember:(NSString *)name object:(id)value; ///------------------------------- -/// @name Subscription Management +/// @name Publish ///------------------------------- -/** - * Adds a new `SRSubscription` to the hubproxy for eventName - * - * @param eventName the `NSString` object representing the name of the subscription event - * @return the `SRSubscription` object created - */ -- (SRSubscription *)subscribe:(NSString *)eventName; - /** * Invokes a SignalR Server Hub method with the specified method name and arguments * calls [self inoke:method arg:args completionHandler]; diff --git a/SignalR.Client/Hubs/SRHubResult.h b/SignalR.Client/Hubs/SRHubResult.h index 210b0eb6..996962a1 100644 --- a/SignalR.Client/Hubs/SRHubResult.h +++ b/SignalR.Client/Hubs/SRHubResult.h @@ -39,11 +39,18 @@ */ @property (strong, nonatomic, readwrite) id result; +@property (assign, nonatomic, readwrite, getter = isHubException) BOOL hubException; + /** * An `NSString` represnting an error received from the server */ @property (strong, nonatomic, readwrite) NSString *error; +/** + * Extra error data + */ +@property (strong, nonatomic, readwrite) id errorData; + /** * An `NSDictionary` represnting a server state object */ diff --git a/SignalR.Client/Hubs/SRHubResult.m b/SignalR.Client/Hubs/SRHubResult.m index b7aa2eef..a8bbeb5d 100644 --- a/SignalR.Client/Hubs/SRHubResult.m +++ b/SignalR.Client/Hubs/SRHubResult.m @@ -30,7 +30,9 @@ @implementation SRHubResult static NSString * const kId = @"I"; static NSString * const kResult = @"R"; +static NSString * const kHubException = @"H"; static NSString * const kError = @"E"; +static NSString * const kErrorData = @"D"; static NSString * const kState = @"S"; - (instancetype) init { @@ -45,7 +47,9 @@ - (instancetype)initWithDictionary:(NSDictionary*)dict { if (self = [self init]) { self.id = dict[kId]; self.result = dict[kResult]; + self.hubException = (dict[kHubException] != nil) ? [dict[kHubException] boolValue] : NO; self.error = dict[kError]; + self.errorData = dict[kErrorData]; self.state = dict[kState]; } return self; diff --git a/SignalR.Client/Hubs/SRHubs.h b/SignalR.Client/Hubs/SRHubs.h index ccbe2b3f..1210d811 100644 --- a/SignalR.Client/Hubs/SRHubs.h +++ b/SignalR.Client/Hubs/SRHubs.h @@ -23,8 +23,6 @@ #import "SRHubConnection.h" #import "SRHubInvocation.h" #import "SRHubProxy.h" -#import "SRHubProxyExtensions.h" #import "SRHubRegistrationData.h" #import "SRHubResult.h" -#import "SRHubservable.h" #import "SRSubscription.h" diff --git a/SignalR.Client/Hubs/SRHubservable.h b/SignalR.Client/Hubs/SRHubservable.h deleted file mode 100644 index ce8a27ae..00000000 --- a/SignalR.Client/Hubs/SRHubservable.h +++ /dev/null @@ -1,90 +0,0 @@ -// -// SRHubservable.h -// SignalR -// -// Created by Alex Billingsley on 11/4/11. -// Copyright (c) 2011 DyKnow LLC. (http://dyknow.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -// to permit persons to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of -// the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - -#import -#import "SRHubProxyInterface.h" - -@class SRSubscription; - -/** - * An `SRHubservable` object provides interface for adding Subscriptions to an SRHubProxy - */ -@interface SRHubservable : NSObject - -///------------------------------- -/// @name Properties -///------------------------------- - -/** - * An `NSString` object representing the name of the subscription event - */ -@property (strong, nonatomic, readonly) NSString *eventName; - -/** - * An `SRHubProxy` object representing the Hub to be observed - */ -@property (strong, nonatomic, readonly) id proxy; - -///------------------------------- -/// @name Initializing an SRHubservable Object -///------------------------------- - -/** - * A convenience method for initWithProxy:(SRHubProxy *)proxy eventName:(NSString *)eventName; - * - * - * SRHubservable *observable = [SRHubservable observe:myHub event:@"myEvent"]; - * - * - * @param proxy the `SRHubProxy` object representing the Hub to be observed - * @param eventName the `NSString` object representing the name of the subscription event - * @return an `SRHubservable` object - */ -+ (instancetype)observe:(id )proxy event:(NSString *)eventName; - -/** - * Initializes a new `SRHubservable` object - * - * - * SRHubservable *observable = [SRHubservable observe:myHub event:@"myEvent"]; - * - * - * @param proxy the `SRHubProxy` object representing the Hub to be observed - * @param eventName the `NSString` object representing the name of the subscription event - * @return an `SRHubservable` object - */ -- (instancetype)initWithProxy:(id )proxy eventName:(NSString *)eventName; - -///------------------------------- -/// @name Adding Subscriptions -///------------------------------- - -/** - * Adds a new Subscription to the underlying proxy for eventName - * - * @param object The receiver to perform selector on - * @param selector A selector identifying the message to send. - * @return the `SRSubscription` object created - */ -- (SRSubscription *)subscribe:(NSObject *)object selector:(SEL)selector; - -@end diff --git a/SignalR.Client/Hubs/SRHubservable.m b/SignalR.Client/Hubs/SRHubservable.m deleted file mode 100644 index 3e45edc7..00000000 --- a/SignalR.Client/Hubs/SRHubservable.m +++ /dev/null @@ -1,59 +0,0 @@ -// -// SRHubservable.m -// SignalR -// -// Created by Alex Billingsley on 11/4/11. -// Copyright (c) 2011 DyKnow LLC. (http://dyknow.com/) -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated -// documentation files (the "Software"), to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and -// to permit persons to whom the Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all copies or substantial portions of -// the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO -// THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF -// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. -// - -#import "SRHubservable.h" -#import "SRSubscription.h" - -@interface SRHubservable () - -@end - -@implementation SRHubservable - -#pragma mark - -#pragma mark Initialization - -+ (instancetype)observe:(id )proxy event:(NSString *)eventName { - return [[SRHubservable alloc] initWithProxy:proxy eventName:eventName]; -} - -- (instancetype)initWithProxy:(id )proxy eventName:(NSString *)eventName { - if (self = [super init]) { - _proxy = proxy; - _eventName = eventName; - } - return self; -} - -- (SRSubscription *)subscribe:(NSObject *)object selector:(SEL)selector { - SRSubscription *subscription = [_proxy subscribe:_eventName]; - subscription.object = object; - subscription.selector = selector; - - return subscription; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"Hubservable: Hub:%@ Event=%@",_proxy, _eventName]; -} - -@end diff --git a/SignalR.Client/Transports/SRWebSocketTransport.m b/SignalR.Client/Transports/SRWebSocketTransport.m index 1aa463e9..111c9908 100644 --- a/SignalR.Client/Transports/SRWebSocketTransport.m +++ b/SignalR.Client/Transports/SRWebSocketTransport.m @@ -75,14 +75,14 @@ - (void)send:(id)connection data:(NSString *)data connect } - (void)abort:(id )connection timeout:(NSNumber *)timeout { - [_webSocket close]; [_webSocket setDelegate:nil]; + [_webSocket close]; _webSocket = nil; } - (void)lostConnection:(id)connection { - [_webSocket close]; [_webSocket setDelegate:nil]; + [_webSocket close]; _webSocket = nil; } From e95ffcba41b7685acc735c8401b0a2705afd19d9 Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Thu, 23 Jan 2014 13:12:45 -0500 Subject: [PATCH 3/7] Fix Transport fallback logic. If Websockets fails on start fallback to SSE if SSE Fails fall all the way down to LP --- SignalR.Client/Transports/SRAutoTransport.m | 2 +- SignalR.Client/Transports/SRHttpBasedTransport.m | 9 +++------ SignalR.Client/Transports/SRWebSocketTransport.m | 13 +++++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SignalR.Client/Transports/SRAutoTransport.m b/SignalR.Client/Transports/SRAutoTransport.m index ef00fed2..b40f7aea 100644 --- a/SignalR.Client/Transports/SRAutoTransport.m +++ b/SignalR.Client/Transports/SRAutoTransport.m @@ -98,7 +98,7 @@ - (void)start:(id )connection connectionData:(NSString *) __strong __typeof(&*weakConnection)strongConnection = weakConnection; __strong __typeof(&*transport)strongTransport = transport; - if ([response isKindOfClass:[NSError class]]) { + if (error) { SRLogAutoTransport(@"will switch to next transport"); // If that transport fails to initialize then fallback diff --git a/SignalR.Client/Transports/SRHttpBasedTransport.m b/SignalR.Client/Transports/SRHttpBasedTransport.m index bb8d85b7..1b398db5 100644 --- a/SignalR.Client/Transports/SRHttpBasedTransport.m +++ b/SignalR.Client/Transports/SRHttpBasedTransport.m @@ -303,17 +303,14 @@ - (void)processResponse:(id )connection } id messages = result[@"M"]; - if(messages && [messages isKindOfClass:[NSArray class]]) - { + if(messages && [messages isKindOfClass:[NSArray class]]) { connection.messageId = result[@"C"]; - for (id message in messages) - { + for (id message in messages) { [connection didReceiveData:message]; } - if ([result[@"S"] boolValue]) - { + if ([result[@"S"] boolValue]) { //TODO: Call Initialized Callback //onInitialized(); } diff --git a/SignalR.Client/Transports/SRWebSocketTransport.m b/SignalR.Client/Transports/SRWebSocketTransport.m index 111c9908..566acae9 100644 --- a/SignalR.Client/Transports/SRWebSocketTransport.m +++ b/SignalR.Client/Transports/SRWebSocketTransport.m @@ -143,10 +143,15 @@ - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message { - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error { SRLogWebSocket(@"Websocket Failed With Error %@, %@", [[_connectionInfo connection] connectionId], error); - [[_connectionInfo connection] didReceiveError:error]; - - if ([SRConnection ensureReconnecting:[_connectionInfo connection]]) { - [self performConnect:nil reconnecting:YES]; + if (self.startBlock) { + self.startBlock(nil,error); + self.startBlock = nil; + } else { + [[_connectionInfo connection] didReceiveError:error]; + + if ([SRConnection ensureReconnecting:[_connectionInfo connection]]) { + [self performConnect:nil reconnecting:YES]; + } } } From 694d0f7b1e8013026c14fe4445ba6d000bca2b06 Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Wed, 19 Feb 2014 16:06:30 -0500 Subject: [PATCH 4/7] Let AFNetworking take care of Serializing the Requests Cleanup Public APIs Remove unused code Change QueryString on SRConnection to NSDictionary for easier usage later. --- Podfile | 4 +- Podfile.lock | 18 +- .../Controllers/ChatViewController.m | 16 +- .../ConnectionStatusViewController.m | 2 +- .../Controllers/MouseTrackingViewController.m | 2 +- .../Controllers/RawViewController.m | 16 +- .../Controllers/StreamingViewController.m | 2 +- SignalR.Client/Hubs/SRHubConnection.h | 3 +- SignalR.Client/Hubs/SRHubConnection.m | 21 +- .../Hubs/SRHubConnectionInterface.h | 4 +- SignalR.Client/Hubs/SRHubInvocation.m | 4 - SignalR.Client/Hubs/SRHubProxy.m | 14 +- SignalR.Client/Hubs/SRHubProxyInterface.h | 2 +- SignalR.Client/Hubs/SRHubRegistrationData.m | 4 - SignalR.Client/Hubs/SRHubResult.m | 4 - SignalR.Client/Hubs/SRSubscription.m | 4 - SignalR.Client/SRConnection.h | 40 ++-- SignalR.Client/SRConnection.m | 36 +--- SignalR.Client/SRConnectionInterface.h | 3 +- SignalR.Client/SRHeartbeatMonitor.m | 4 +- SignalR.Client/SRLog.h | 2 +- SignalR.Client/SRNegotiationResponse.m | 4 - SignalR.Client/Transports/SRAutoTransport.h | 5 +- SignalR.Client/Transports/SRAutoTransport.m | 4 +- .../Transports/SRHttpBasedTransport.h | 2 - .../Transports/SRHttpBasedTransport.m | 203 +++++------------- .../Transports/SRLongPollingTransport.m | 32 ++- .../Transports/SRServerSentEventsTransport.m | 36 ++-- .../Transports/SRWebSocketTransport.m | 36 ++-- .../SREventSourceStreamReader.h | 12 +- 30 files changed, 208 insertions(+), 331 deletions(-) diff --git a/Podfile b/Podfile index 5fb732ba..1a947f48 100644 --- a/Podfile +++ b/Podfile @@ -3,13 +3,13 @@ workspace 'SignalR.Client.ObjC' target :"SignalR.Client.iOS", :exclusive => true do platform :ios, '6.0' - pod 'AFNetworking', '2.0.2' + pod 'AFNetworking', '2.1.0' pod 'SocketRocket', '0.3.1-beta2' end target :"SignalR.Client.OSX", :exclusive => true do platform :osx, '10.8' - pod 'AFNetworking', '2.0.2' + pod 'AFNetworking', '2.1.0' pod 'SocketRocket', '0.3.1-beta2' end diff --git a/Podfile.lock b/Podfile.lock index 9e3b85c4..e39d3d4e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,32 +1,32 @@ PODS: - - AFNetworking (2.0.2): + - AFNetworking (2.1.0): - AFNetworking/NSURLConnection - AFNetworking/NSURLSession - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - AFNetworking/UIKit - - AFNetworking/NSURLConnection (2.0.2): + - AFNetworking/NSURLConnection (2.1.0): - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - - AFNetworking/NSURLSession (2.0.2): + - AFNetworking/NSURLSession (2.1.0): - AFNetworking/NSURLConnection - - AFNetworking/Reachability (2.0.2) - - AFNetworking/Security (2.0.2) - - AFNetworking/Serialization (2.0.2) - - AFNetworking/UIKit (2.0.2): + - AFNetworking/Reachability (2.1.0) + - AFNetworking/Security (2.1.0) + - AFNetworking/Serialization (2.1.0) + - AFNetworking/UIKit (2.1.0): - AFNetworking/NSURLConnection - OCMock (2.2.2) - SocketRocket (0.3.1-beta2) DEPENDENCIES: - - AFNetworking (= 2.0.2) + - AFNetworking (= 2.1.0) - OCMock - SocketRocket (= 0.3.1-beta2) SPEC CHECKSUMS: - AFNetworking: e663917201cdb73f4ad2ba239ad35be8dc9a1e3c + AFNetworking: c7d7901a83f631414c7eda1737261f696101a5cd OCMock: ffba68873fd32cfd35d885bddad23bfa816da4a3 SocketRocket: 7ac946bcce46287a791dfff3c1f8daa692821dae diff --git a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ChatViewController.m b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ChatViewController.m index d5126633..110ff602 100644 --- a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ChatViewController.m +++ b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ChatViewController.m @@ -110,7 +110,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (IBAction)connectClicked:(id)sender { NSString *server = [Router sharedRouter].server_url; - connection = [SRHubConnection connectionWithURL:server]; + connection = [SRHubConnection connectionWithURLString:server]; hub = [connection createHubProxy:@"Chat"]; [[hub state] setValue:@YES forKey:@"focus"]; @@ -177,13 +177,15 @@ -(void)refreshRoom:(id)inRoom [self clearMessages]; [self clearUsers]; - [hub invoke:@"GetUsers" withArgs:@[] completionHandler:^(id users) { - for(id user in users) - { - if([user isKindOfClass:[NSDictionary class]]){ - [self addUser:user exists:TRUE]; + [hub invoke:@"GetUsers" withArgs:@[] completionHandler:^(id users, NSError *error) { + if (!error) { + for(id user in users) + { + if([user isKindOfClass:[NSDictionary class]]){ + [self addUser:user exists:TRUE]; + } + [self refreshUsers]; } - [self refreshUsers]; } }]; diff --git a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ConnectionStatusViewController.m b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ConnectionStatusViewController.m index 69f0d2ea..cf92d4aa 100644 --- a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ConnectionStatusViewController.m +++ b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/ConnectionStatusViewController.m @@ -64,7 +64,7 @@ - (void)viewDidLoad } __weak __typeof(&*self)weakSelf = self; - _connection = [SRHubConnection connectionWithURL:[Router sharedRouter].server_url]; + _connection = [SRHubConnection connectionWithURLString:[Router sharedRouter].server_url]; _hub = [_connection createHubProxy:@"statushub"]; [_hub on:@"joined" perform:self selector:@selector(joined:when:)]; [_hub on:@"rejoined" perform:self selector:@selector(rejoined:when:)]; diff --git a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/MouseTrackingViewController.m b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/MouseTrackingViewController.m index bf8a056a..84fa6cb3 100644 --- a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/MouseTrackingViewController.m +++ b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/MouseTrackingViewController.m @@ -70,7 +70,7 @@ - (void)viewDidLoad } __weak __typeof(&*self)weakSelf = self; - _connection = [SRHubConnection connectionWithURL:[Router sharedRouter].server_url]; + _connection = [SRHubConnection connectionWithURLString:[Router sharedRouter].server_url]; _hub = [_connection createHubProxy:@"MouseTracking"]; [_hub on:@"move" perform:self selector:@selector(moveMouse:x:y:)]; _connection.started = ^{ diff --git a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/RawViewController.m b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/RawViewController.m index 161765ed..0731db46 100644 --- a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/RawViewController.m +++ b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/RawViewController.m @@ -100,7 +100,7 @@ - (IBAction)connectClicked:(id)sender { NSString *server = [Router sharedRouter].server_url; server = [server stringByAppendingFormat:@"raw-connection"]; - connection = [SRConnection connectionWithURL:server]; + connection = [SRConnection connectionWithURLString:server]; [connection setDelegate:self]; [connection start]; @@ -116,7 +116,7 @@ - (IBAction)sendClicked:(id)sender message[@"type"] = @0; message[@"value"] = meField.text; - [connection send:message]; + [connection send:message completionHandler:nil]; } - (IBAction)broadcastClicked:(id)sender @@ -125,7 +125,7 @@ - (IBAction)broadcastClicked:(id)sender message[@"type"] = @1; message[@"value"] = messageField.text; - [connection send:message]; + [connection send:message completionHandler:nil]; } - (IBAction)enternameClicked:(id)sender @@ -134,7 +134,7 @@ - (IBAction)enternameClicked:(id)sender message[@"type"] = @2; message[@"value"] = messageField.text; - [connection send:message]; + [connection send:message completionHandler:nil]; } - (IBAction)sendToUserClicked:(id)sender @@ -143,7 +143,7 @@ - (IBAction)sendToUserClicked:(id)sender message[@"type"] = @3; message[@"value"] = [NSString stringWithFormat:@"%@|%@",privateMessageToField.text,privateMessageField.text]; - [connection send:message]; + [connection send:message completionHandler:nil]; } - (IBAction)joingroupClicked:(id)sender @@ -152,7 +152,7 @@ - (IBAction)joingroupClicked:(id)sender message[@"type"] = @4; message[@"value"] = messageField.text; - [connection send:message]; + [connection send:message completionHandler:nil]; } - (IBAction)leavegroupClicked:(id)sender @@ -161,7 +161,7 @@ - (IBAction)leavegroupClicked:(id)sender message[@"type"] = @5; message[@"value"] = messageField.text; - [connection send:message]; + [connection send:message completionHandler:nil]; } - (IBAction)sendToGroupClicked:(id)sender @@ -170,7 +170,7 @@ - (IBAction)sendToGroupClicked:(id)sender message[@"type"] = @6; message[@"value"] = [NSString stringWithFormat:@"%@|%@",privateMessageToField.text,privateMessageField.text]; - [connection send:message]; + [connection send:message completionHandler:nil]; } - (IBAction)stopClicked:(id)sender diff --git a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/StreamingViewController.m b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/StreamingViewController.m index af64a876..20a6c3f8 100644 --- a/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/StreamingViewController.m +++ b/SignalR.Client.ObjC/SignalR.Samples.iOS/Controllers/StreamingViewController.m @@ -63,7 +63,7 @@ - (void)viewDidLoad } __weak __typeof(&*self)weakSelf = self; - _connection = [SRConnection connectionWithURL:[[Router sharedRouter].server_url stringByAppendingFormat:@"streaming-connection"]]; + _connection = [SRConnection connectionWithURLString:[[Router sharedRouter].server_url stringByAppendingFormat:@"streaming-connection"]]; _connection.started = ^{ __strong __typeof(&*weakSelf)strongSelf = weakSelf; [strongSelf.data insertObject:@"Connection Opened" atIndex:0]; diff --git a/SignalR.Client/Hubs/SRHubConnection.h b/SignalR.Client/Hubs/SRHubConnection.h index 6767bdb8..0721eee4 100644 --- a/SignalR.Client/Hubs/SRHubConnection.h +++ b/SignalR.Client/Hubs/SRHubConnection.h @@ -32,8 +32,7 @@ @interface SRHubConnection : SRConnection - (instancetype)initWithURLString:(NSString *)URL useDefault:(BOOL)useDefault; -- (instancetype)initWithURLString:(NSString *)url queryString:(NSString *)queryString useDefault:(BOOL)useDefault; -- (instancetype)initWithURLString:(NSString *)url query:(NSDictionary *)queryString useDefault:(BOOL)useDefault; +- (instancetype)initWithURLString:(NSString *)url queryString:(NSDictionary *)queryString useDefault:(BOOL)useDefault; /** * Creates a client side proxy to the hub on the server side. diff --git a/SignalR.Client/Hubs/SRHubConnection.m b/SignalR.Client/Hubs/SRHubConnection.m index c2ceb99b..3a1f64e8 100644 --- a/SignalR.Client/Hubs/SRHubConnection.m +++ b/SignalR.Client/Hubs/SRHubConnection.m @@ -55,23 +55,12 @@ - (instancetype)initWithURLString:(NSString *)URL useDefault:(BOOL)useDefault { return self; } -- (instancetype)initWithURLString:(NSString *)url queryString:(NSString *)queryString { +- (instancetype)initWithURLString:(NSString *)url queryString:(NSDictionary *)queryString { return [self initWithURLString:url queryString:queryString useDefault:YES]; } -- (instancetype)initWithURLString:(NSString *)url queryString:(NSString *)queryString useDefault:(BOOL)useDefault { +- (instancetype)initWithURLString:(NSString *)url queryString:(NSDictionary *)queryString useDefault:(BOOL)useDefault { if (self = [super initWithURLString:[[self class] getUrl:url useDefault:useDefault] queryString:queryString]) { - [self commonInit]; - } - return self; -} - -- (instancetype)initWithURLString:(NSString *)url query:(NSDictionary *)queryString { - return [self initWithURLString:url query:queryString useDefault:YES]; -} - -- (instancetype)initWithURLString:(NSString *)url query:(NSDictionary *)queryString useDefault:(BOOL)useDefault { - if (self = [super initWithURLString:[[self class] getUrl:url useDefault:useDefault] query:queryString]) { [self commonInit]; } return self; @@ -97,7 +86,7 @@ - (void)commonInit { return hubProxy; } -- (NSString *)registerCallback:(SRHubResultBlock)callback { +- (NSString *)registerCallback:(SRHubConnectionHubResultBlock)callback { NSString *newId = [[NSNumber numberWithInt:_callbackId] stringValue]; _callbacks[newId] = callback; _callbackId += 1; @@ -112,7 +101,7 @@ - (void)clearInvocationCallbacks:(NSString *)error { SRHubResult *result = [[SRHubResult alloc] init]; [result setError:error]; - for (SRHubResultBlock callback in [self.callbacks allValues]) { + for (SRHubConnectionHubResultBlock callback in [self.callbacks allValues]) { callback(result); } @@ -156,7 +145,7 @@ - (void)didReceiveData:(id)data { if([data isKindOfClass:[NSDictionary class]]) { if ([data valueForKey:@"I"]) { SRHubResult *result = [[SRHubResult alloc] initWithDictionary:data]; - SRHubResultBlock callback = _callbacks[result.id]; + SRHubConnectionHubResultBlock callback = _callbacks[result.id]; if (callback) { [_callbacks removeObjectForKey:result.id]; callback(result); diff --git a/SignalR.Client/Hubs/SRHubConnectionInterface.h b/SignalR.Client/Hubs/SRHubConnectionInterface.h index 1ef50381..0c640ce3 100644 --- a/SignalR.Client/Hubs/SRHubConnectionInterface.h +++ b/SignalR.Client/Hubs/SRHubConnectionInterface.h @@ -25,11 +25,11 @@ @protocol SRConnectionInterface; @class SRHubResult; -typedef void (^SRHubResultBlock)(SRHubResult *result); +typedef void (^SRHubConnectionHubResultBlock)(SRHubResult *result); @protocol SRHubConnectionInterface -- (NSString *)registerCallback:(SRHubResultBlock)callback; +- (NSString *)registerCallback:(SRHubConnectionHubResultBlock)callback; - (void)removeCallback:(NSString *)callbackId; @end diff --git a/SignalR.Client/Hubs/SRHubInvocation.m b/SignalR.Client/Hubs/SRHubInvocation.m index 0c25a998..9f39187a 100644 --- a/SignalR.Client/Hubs/SRHubInvocation.m +++ b/SignalR.Client/Hubs/SRHubInvocation.m @@ -68,8 +68,4 @@ - (id)proxyForJson { return dict; } -- (NSString *)description { - return [NSString stringWithFormat:@"HubInvocation: CallbackId=%@ Hub=%@ Method=%@",_callbackId,_hub,_method]; -} - @end diff --git a/SignalR.Client/Hubs/SRHubProxy.m b/SignalR.Client/Hubs/SRHubProxy.m index 3cb624ff..880714d0 100644 --- a/SignalR.Client/Hubs/SRHubProxy.m +++ b/SignalR.Client/Hubs/SRHubProxy.m @@ -107,7 +107,7 @@ - (void)invoke:(NSString *)method withArgs:(NSArray *)args { [self invoke:method withArgs:args completionHandler:nil]; } -- (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(void (^)(id response))block { +- (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(void (^)(id response, NSError *error))block { if(method == nil || [method isEqualToString:@""]) { [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Argument method is null",@"NSInvalidArgumentException")]; } @@ -127,7 +127,7 @@ - (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(vo userInfo:userInfo]; [_connection didReceiveError:error]; if (block != nil) { - block(error); + block(nil, error); } } else { if(result.state != nil && ![result.state isKindOfClass:[NSNull class]]) { @@ -138,11 +138,11 @@ - (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(vo if(result.result != nil && ![result.result isKindOfClass:[NSNull class]]) { if (block != nil) { - block(result.result); + block(result.result, nil); } } else { if (block != nil) { - block(@{}); + block(nil, nil); } } } @@ -159,11 +159,7 @@ - (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(vo hubData.state = _state; } - [_connection send:hubData]; -} - -- (NSString *)description { - return [NSString stringWithFormat:@"HubProxy: Name=%@ State=%@ Subscriptions:%@",_hubName,_state,_subscriptions]; + [_connection send:hubData completionHandler:block]; } @end diff --git a/SignalR.Client/Hubs/SRHubProxyInterface.h b/SignalR.Client/Hubs/SRHubProxyInterface.h index 2ed1bee0..cbf3f109 100644 --- a/SignalR.Client/Hubs/SRHubProxyInterface.h +++ b/SignalR.Client/Hubs/SRHubProxyInterface.h @@ -61,6 +61,6 @@ * @param args the arguments to pass as part of the invocation * @param block the block to be called once the server method is invoked, this may be nil */ -- (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(void (^)(id response))block; +- (void)invoke:(NSString *)method withArgs:(NSArray *)args completionHandler:(void (^)(id response, NSError *error))block; @end diff --git a/SignalR.Client/Hubs/SRHubRegistrationData.m b/SignalR.Client/Hubs/SRHubRegistrationData.m index 5273e36b..d87ec7b9 100644 --- a/SignalR.Client/Hubs/SRHubRegistrationData.m +++ b/SignalR.Client/Hubs/SRHubRegistrationData.m @@ -45,8 +45,4 @@ - (id)proxyForJson { return dict; } -- (NSString *)description { - return [NSString stringWithFormat:@"HubRegistrationData: Name=%@",_name]; -} - @end diff --git a/SignalR.Client/Hubs/SRHubResult.m b/SignalR.Client/Hubs/SRHubResult.m index a8bbeb5d..957fb110 100644 --- a/SignalR.Client/Hubs/SRHubResult.m +++ b/SignalR.Client/Hubs/SRHubResult.m @@ -55,8 +55,4 @@ - (instancetype)initWithDictionary:(NSDictionary*)dict { return self; } -- (NSString *)description { - return [NSString stringWithFormat:@"HubResult: Id=%@ Result:%@ Error=%@ State=%@",_id,_result,_error,_state]; -} - @end diff --git a/SignalR.Client/Hubs/SRSubscription.m b/SignalR.Client/Hubs/SRSubscription.m index 3583f77c..95daf5da 100644 --- a/SignalR.Client/Hubs/SRSubscription.m +++ b/SignalR.Client/Hubs/SRSubscription.m @@ -28,8 +28,4 @@ @interface SRSubscription () @implementation SRSubscription -- (NSString *)description { - return [NSString stringWithFormat:@"Subscription: Object:%@ Selector=%@",_object, NSStringFromSelector(_selector)]; -} - @end diff --git a/SignalR.Client/SRConnection.h b/SignalR.Client/SRConnection.h index e26ac883..f9706350 100644 --- a/SignalR.Client/SRConnection.h +++ b/SignalR.Client/SRConnection.h @@ -27,14 +27,14 @@ @class SRConnection; -typedef void (^onStarted)(); -typedef void (^onReceived)(id); -typedef void (^onError)(NSError *); -typedef void (^onClosed)(); -typedef void (^onReconnecting)(); -typedef void (^onReconnected)(); -typedef void (^onStateChanged)(connectionState); -typedef void (^onConnectionSlow)(); +typedef void (^SRConnectionStartedBlock)(); +typedef void (^SRConnectionReceivedBlock)(id); +typedef void (^SRConnectionErrorBlock)(NSError *); +typedef void (^SRConnectionClosedBlock)(); +typedef void (^SRConnectionReconnectingBlock)(); +typedef void (^SRConnectionReconnectedBlock)(); +typedef void (^SRConnectionStateChangedBlock)(connectionState); +typedef void (^SRConnectionConnectionSlowBlock)(); @interface SRConnection : NSObject @@ -42,14 +42,14 @@ typedef void (^onConnectionSlow)(); /// @name Properties ///------------------------------- -@property (copy) onStarted started; -@property (copy) onReceived received; -@property (copy) onError error; -@property (copy) onClosed closed; -@property (copy) onReconnecting reconnecting; -@property (copy) onReconnected reconnected; -@property (copy) onStateChanged stateChanged; -@property (copy) onConnectionSlow connectionSlow; +@property (copy) SRConnectionStartedBlock started; +@property (copy) SRConnectionReceivedBlock received; +@property (copy) SRConnectionErrorBlock error; +@property (copy) SRConnectionClosedBlock closed; +@property (copy) SRConnectionReconnectingBlock reconnecting; +@property (copy) SRConnectionReconnectedBlock reconnected; +@property (copy) SRConnectionStateChangedBlock stateChanged; +@property (copy) SRConnectionConnectionSlowBlock connectionSlow; @property (nonatomic, assign) id delegate; @@ -57,12 +57,10 @@ typedef void (^onConnectionSlow)(); /// @name Initializing an SRConnection Object ///------------------------------- -+ (instancetype)connectionWithURL:(NSString *)URL; -+ (instancetype)connectionWithURL:(NSString *)url query:(NSDictionary *)queryString; -+ (instancetype)connectionWithURL:(NSString *)url queryString:(NSString *)queryString; ++ (instancetype)connectionWithURLString:(NSString *)URL; ++ (instancetype)connectionWithURLString:(NSString *)url queryString:(NSDictionary *)queryString; - (instancetype)initWithURLString:(NSString *)url; -- (instancetype)initWithURLString:(NSString *)url query:(NSDictionary *)queryString; -- (instancetype)initWithURLString:(NSString *)url queryString:(NSString *)queryString; +- (instancetype)initWithURLString:(NSString *)url queryString:(NSDictionary *)queryString; ///------------------------------- /// @name Connection Management diff --git a/SignalR.Client/SRConnection.m b/SignalR.Client/SRConnection.m index 82e1def1..db039eba 100644 --- a/SignalR.Client/SRConnection.m +++ b/SignalR.Client/SRConnection.m @@ -31,8 +31,6 @@ #import "NSObject+SRJSON.h" -void (^prepareRequest)(id); - @interface SRConnection () @property (strong, nonatomic, readwrite) NSNumber * defaultAbortTimeout; @@ -43,13 +41,12 @@ @interface SRConnection () @property (assign, nonatomic, readwrite) connectionState state; @property (strong, nonatomic, readwrite) NSString *url; @property (strong, nonatomic, readwrite) NSMutableDictionary *items; -@property (strong, nonatomic, readwrite) NSString *queryString; +@property (strong, nonatomic, readwrite) NSDictionary *queryString; @property (strong, nonatomic, readwrite) NSString *connectionData; @property (strong, nonatomic, readwrite) SRHeartbeatMonitor *monitor; - (void)negotiate:(id )transport; - (void)verifyProtocolVersion:(NSString *)versionString; -- (NSString *)createQueryString:(NSDictionary *)queryString; - (NSString *)createUserAgentString:(NSString *)client; @end @@ -74,15 +71,11 @@ @implementation SRConnection #pragma mark - #pragma mark Initialization -+ (instancetype)connectionWithURL:(NSString *)url { ++ (instancetype)connectionWithURLString:(NSString *)url { return [[[self class] alloc] initWithURLString:url]; } -+ (instancetype)connectionWithURL:(NSString *)url query:(NSDictionary *)queryString { - return [[[self class] alloc] initWithURLString:url query:queryString]; -} - -+ (instancetype)connectionWithURL:(NSString *)url queryString:(NSString *)queryString { ++ (instancetype)connectionWithURLString:(NSString *)url queryString:(NSDictionary *)queryString { return [[[self class] alloc] initWithURLString:url queryString:queryString]; } @@ -90,20 +83,12 @@ - (instancetype)initWithURLString:(NSString *)url { return [self initWithURLString:url queryString:nil]; } -- (instancetype)initWithURLString:(NSString *)url query:(NSDictionary *)queryString { - return [self initWithURLString:url queryString:[self createQueryString:queryString]]; -} - -- (instancetype)initWithURLString:(NSString *)url queryString:(NSString *)queryString { +- (instancetype)initWithURLString:(NSString *)url queryString:(NSDictionary *)queryString { if (self = [super init]) { if (url == nil) { [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Url should be non-null",@"")]; } - if(queryString && [queryString rangeOfString:@"?" options:NSCaseInsensitiveSearch].location != NSNotFound) { - [NSException raise:NSInvalidArgumentException format:NSLocalizedString(@"Url cannot contain query string directly. Pass query string values in using available overload.",@"")]; - } - if([url hasSuffix:@"/"] == NO) { url = [url stringByAppendingString:@"/"]; } @@ -266,10 +251,6 @@ - (NSString *)onSending { return nil; } -- (void)send:(id)object { - [self send:object completionHandler:nil]; -} - - (void)send:(id)object completionHandler:(void (^)(id response, NSError *error))block { if (self.state == disconnected) { NSMutableDictionary *userInfo = [NSMutableDictionary dictionary]; @@ -440,13 +421,4 @@ - (NSString *)createUserAgentString:(NSString *)client { #endif } -- (NSString *)createQueryString:(NSDictionary *)queryString { - NSMutableArray *components = [NSMutableArray array]; - for (NSString *key in [queryString allKeys]) { - [components addObject:[NSString stringWithFormat:@"%@=%@",key,queryString[key]]]; - } - - return [components componentsJoinedByString:@"&"]; -} - @end diff --git a/SignalR.Client/SRConnectionInterface.h b/SignalR.Client/SRConnectionInterface.h index 66ce1776..60c24613 100644 --- a/SignalR.Client/SRConnectionInterface.h +++ b/SignalR.Client/SRConnectionInterface.h @@ -42,7 +42,7 @@ @property (strong, nonatomic, readonly) NSString *connectionId; @property (strong, nonatomic, readonly) NSString *connectionToken; @property (strong, nonatomic, readonly) NSString *url; -@property (strong, nonatomic, readonly) NSString *queryString; +@property (strong, nonatomic, readonly) NSDictionary *queryString; @property (assign, nonatomic, readonly) connectionState state; @property (strong, nonatomic, readonly) id transport; @property (strong, nonatomic, readwrite) NSURLCredential *credentials; @@ -60,7 +60,6 @@ /// @name Sending Data ///------------------------------- -- (void)send:(id)object; - (void)send:(id)object completionHandler:(void (^)(id response, NSError *error))block; ///------------------------------- diff --git a/SignalR.Client/SRHeartbeatMonitor.m b/SignalR.Client/SRHeartbeatMonitor.m index ae2f6676..84088229 100644 --- a/SignalR.Client/SRHeartbeatMonitor.m +++ b/SignalR.Client/SRHeartbeatMonitor.m @@ -64,14 +64,14 @@ - (void)beat:(NSInteger)timeElapsed { if (timeElapsed >= [[[_connection keepAliveData] timeout] integerValue]) { if (!self.timedOut) { // Connection has been lost - SRLogConnection("Connection Timed-out : Transport Lost Connection"); + SRLogConnection(@"Connection Timed-out : Transport Lost Connection"); _timedOut = true; [[_connection transport] lostConnection:_connection]; } } else if (timeElapsed >= [[[_connection keepAliveData] timeoutWarning] integerValue]) { if (!self.hasBeenWarned) { // Inform user and set HasBeenWarned to true - SRLogConnection("Connection Timeout Warning : Notifying user"); + SRLogConnection(@"Connection Timeout Warning : Notifying user"); _beenWarned = true; [_connection connectionDidSlow]; } diff --git a/SignalR.Client/SRLog.h b/SignalR.Client/SRLog.h index dfe991aa..003a81d6 100644 --- a/SignalR.Client/SRLog.h +++ b/SignalR.Client/SRLog.h @@ -125,7 +125,7 @@ do{ \ NSLog((@"Thread %@:%s [Line %d]\n[HTTP_BASED_TRANSPORT] " fmt), [NSThread currentThread], __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); \ } while(0) -#define SRLogWebSocket(fmt, ...) \ +#define SRLogWebSockets(fmt, ...) \ do{ \ if(ddLogLevel & LOG_WEBSOCKETS) \ NSLog((@"Thread %@:%s [Line %d]\n[WEB_SOCKETS] " fmt), [NSThread currentThread], __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); \ diff --git a/SignalR.Client/SRNegotiationResponse.m b/SignalR.Client/SRNegotiationResponse.m index 826cbed7..fc9635bf 100644 --- a/SignalR.Client/SRNegotiationResponse.m +++ b/SignalR.Client/SRNegotiationResponse.m @@ -63,8 +63,4 @@ - (instancetype)initWithDictionary:(NSDictionary*)dict { return self; } -- (NSString *)description { - return [NSString stringWithFormat:@"NegotiationResponse: ConnectionId=%@ ConnectionToken=%@ Url=%@ ProtocolVersion=%@ TryWebSockets=%d",_connectionId,_connectionToken,_url,_protocolVersion,_tryWebSockets]; -} - @end diff --git a/SignalR.Client/Transports/SRAutoTransport.h b/SignalR.Client/Transports/SRAutoTransport.h index 5a52d494..bbdd66b7 100644 --- a/SignalR.Client/Transports/SRAutoTransport.h +++ b/SignalR.Client/Transports/SRAutoTransport.h @@ -28,8 +28,9 @@ * `SRAutoTransport` object provides support for choosing the best transport for the client * * ## Fallback order - * 1. Server-Sent Events SRServerSentEventsTransport - * 1. Long Polling SRLongPollingTransport + * 1. Websockets SRWebSocketTransport + * 2. Server-Sent Events SRServerSentEventsTransport + * 3. Long Polling SRLongPollingTransport */ @interface SRAutoTransport : SRHttpBasedTransport diff --git a/SignalR.Client/Transports/SRAutoTransport.m b/SignalR.Client/Transports/SRAutoTransport.m index b40f7aea..89c89298 100644 --- a/SignalR.Client/Transports/SRAutoTransport.m +++ b/SignalR.Client/Transports/SRAutoTransport.m @@ -33,7 +33,6 @@ @interface SRAutoTransport () @property (strong, nonatomic, readwrite) id transport; // List of transports in fallback order @property (strong, nonatomic, readonly) NSMutableArray *transports; -@property (assign, nonatomic, readwrite) int startIndex; @end @@ -49,7 +48,6 @@ - (instancetype)init { - (instancetype)initWithTransports:(NSMutableArray *)transports { if(self = [super init]) { _transports = transports; - _startIndex = 0; } return self; } @@ -86,7 +84,7 @@ - (void)negotiate:(id)connection connectionData:(NSString } - (void)start:(id)connection connectionData:(NSString *)connectionData completionHandler:(void (^)(id response, NSError *error))block { - [self start:connection connectionData:connectionData transportIndex:self.startIndex completionHandler:block]; + [self start:connection connectionData:connectionData transportIndex:0 completionHandler:block]; } - (void)start:(id )connection connectionData:(NSString *)connectionData transportIndex:(int)index completionHandler:(void (^)(id response, NSError *error))block { diff --git a/SignalR.Client/Transports/SRHttpBasedTransport.h b/SignalR.Client/Transports/SRHttpBasedTransport.h index 23d4e21e..d58b07f0 100644 --- a/SignalR.Client/Transports/SRHttpBasedTransport.h +++ b/SignalR.Client/Transports/SRHttpBasedTransport.h @@ -27,8 +27,6 @@ - (void)completeAbort; - (BOOL)tryCompleteAbort; -- (NSString *)receiveQueryString:(id )connection data:(NSString *)data; -- (NSString *)appendBaseUrl:(NSString *)baseUrl withConnectionQueryString:(id )connection; - (void)processResponse:(id )connection response:(NSString *)response shouldReconnect:(BOOL *)shouldReconnect disconnected:(BOOL *)disconnected; @end diff --git a/SignalR.Client/Transports/SRHttpBasedTransport.m b/SignalR.Client/Transports/SRHttpBasedTransport.m index 1b398db5..4c8e37f4 100644 --- a/SignalR.Client/Transports/SRHttpBasedTransport.m +++ b/SignalR.Client/Transports/SRHttpBasedTransport.m @@ -20,7 +20,7 @@ // DEALINGS IN THE SOFTWARE. // -#import "AFHTTPRequestOperation.h" +#import #import "SRConnectionInterface.h" #import "SRHttpBasedTransport.h" #import "SRLog.h" @@ -34,20 +34,8 @@ @interface SRHttpBasedTransport() @end -static inline NSString * SREscapeData(NSString *string) { - return (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)(NSString *)string, NULL, - (CFStringRef)@"!*'();:@&=+$,/?%#[]", - kCFStringEncodingUTF8)); -} - @implementation SRHttpBasedTransport -- (instancetype)init { - if (self = [super init]) { - } - return self; -} - #pragma mark #pragma mark SRClientTransportInterface @@ -59,34 +47,27 @@ - (BOOL)supportsKeepAlive { return NO; } -- (void)negotiate:(id)connection - connectionData:(NSString *)connectionData -completionHandler:(void (^)(SRNegotiationResponse * response, NSError *error))block { - - NSString *negotiateUrl = [connection.url stringByAppendingString:@"negotiate"]; - negotiateUrl = [negotiateUrl stringByAppendingString:[self appendBaseUrl:negotiateUrl withConnectionQueryString:connection]]; +- (void)negotiate:(id)connection connectionData:(NSString *)connectionData completionHandler:(void (^)(SRNegotiationResponse * response, NSError *error))block { - NSString *appender = @"?"; - if ([negotiateUrl rangeOfString:appender].location != NSNotFound) { - appender = @"&"; - } - negotiateUrl = [negotiateUrl stringByAppendingString:appender]; - negotiateUrl = [negotiateUrl stringByAppendingString:@"clientProtocol="]; - negotiateUrl = [negotiateUrl stringByAppendingFormat:@"%@",connection.protocol]; + id parameters = @{ + @"clientProtocol" : connection.protocol, + @"connectionData" : (connectionData) ? connectionData : @"", + }; - if (connectionData != nil && ![connectionData isEqualToString:@""]) { - negotiateUrl = [negotiateUrl stringByAppendingString:@"&connectionData="]; - negotiateUrl = [negotiateUrl stringByAppendingString:SREscapeData(connectionData)]; + if ([connection queryString]) { + NSMutableDictionary *_parameters = [NSMutableDictionary dictionaryWithDictionary:parameters]; + [_parameters addEntriesFromDictionary:[connection queryString]]; + parameters = _parameters; } - - NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:negotiateUrl]]; - [urlRequest setHTTPMethod:@"GET"]; - [urlRequest setTimeoutInterval:30]; - [connection prepareRequest:urlRequest]; - - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[connection.url stringByAppendingString:@"negotiate"] parameters:parameters error:nil]; + [request setTimeoutInterval:30]; + //TODO: prepareRequest + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; + //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + //operation.credential = self.credential; + //operation.securityPolicy = self.securityPolicy; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { if(block) { block([[SRNegotiationResponse alloc] initWithDictionary:responseObject], nil); @@ -99,42 +80,32 @@ - (void)negotiate:(id)connection [operation start]; } -- (void)start:(id)connection -connectionData:(NSString *)connectionData -completionHandler:(void (^)(id response, NSError *error))block { +- (void)start:(id)connection connectionData:(NSString *)connectionData completionHandler:(void (^)(id response, NSError *error))block { } -- (void)send:(id)connection - data:(NSString *)data -connectionData:(NSString *)connectionData -completionHandler:(void (^)(id response, NSError *error))block { - - SRLogHTTPTransport(@"will send data"); - - NSString *url = [connection.url stringByAppendingString:@"send"]; - url = [url stringByAppendingString:[self sendQueryString:connection connectionData:connectionData]]; - - id postData = @{ - @"data" : data +- (void)send:(id)connection data:(NSString *)data connectionData:(NSString *)connectionData completionHandler:(void (^)(id response, NSError *error))block { + id parameters = @{ + @"transport" : [self name], + @"connectionData" : (connectionData) ? connectionData : @"", + @"connectionToken" : [connection connectionToken], }; - NSMutableArray *components = [NSMutableArray array]; - for (NSString *key in [postData allKeys]) { - [components addObject:[NSString stringWithFormat:@"%@=%@",key,SREscapeData(postData[key])]]; + if ([connection queryString]) { + NSMutableDictionary *_parameters = [NSMutableDictionary dictionaryWithDictionary:parameters]; + [_parameters addEntriesFromDictionary:[connection queryString]]; + parameters = _parameters; } - NSData *requestData = [[components componentsJoinedByString:@"&"] dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; - - NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; - [urlRequest setHTTPMethod:@"POST"]; - [urlRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"]; - [urlRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; - [urlRequest setValue:[NSString stringWithFormat:@"%ld", (unsigned long)[requestData length]] forHTTPHeaderField:@"Content-Length"]; - [urlRequest setHTTPBody: requestData]; - - [connection prepareRequest:urlRequest]; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + //TODO: this is a little strange but SignalR Expects the parameters in the queryString and fails if in the body. + //So we let AFNetworking Generate our URL with proper encoding and then create the POST url which will encode the data in the body. + NSMutableURLRequest *url = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[connection.url stringByAppendingString:@"send"] parameters:parameters error:nil]; + NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:[[url URL] absoluteString] parameters:@{ @"data" : data } error:nil]; + //TODO: prepareRequest + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; + //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + //operation.credential = self.credential; + //operation.securityPolicy = self.securityPolicy; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { [connection didReceiveData:responseObject]; if(block) { @@ -167,9 +138,7 @@ - (void)lostConnection:(id)connection { //TODO: Throw, Subclass should implement this. } -- (void)abort:(id)connection - timeout:(NSNumber *)timeout -connectionData:(NSString *)connectionData { +- (void)abort:(id)connection timeout:(NSNumber *)timeout connectionData:(NSString *)connectionData { // Ensure that an abort request is only made once if (!_startedAbort) @@ -177,18 +146,27 @@ - (void)abort:(id)connection SRLogHTTPTransport(@"will stop transport"); _startedAbort = YES; - NSString *url = [connection.url stringByAppendingString:@"abort"]; - url = [url stringByAppendingString:[self sendQueryString:connection connectionData:connectionData]]; + id parameters = @{ + @"transport" : [self name], + @"connectionData" : (connectionData) ? connectionData : @"", + @"connectionToken" : [connection connectionToken], + }; - NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; - [urlRequest setHTTPMethod:@"POST"]; - [urlRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"]; - //[urlRequest setTimeoutInterval:2]; - - [connection prepareRequest:urlRequest]; + if ([connection queryString]) { + NSMutableDictionary *_parameters = [NSMutableDictionary dictionaryWithDictionary:parameters]; + [_parameters addEntriesFromDictionary:[connection queryString]]; + parameters = _parameters; + } - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + NSMutableURLRequest *url = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[connection.url stringByAppendingString:@"abort"] parameters:parameters error:nil]; + NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:[[url URL] absoluteString] parameters:nil error:nil]; + [request setTimeoutInterval:2]; + //TODO: prepareRequest + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; + //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + //operation.credential = self.credential; + //operation.securityPolicy = self.securityPolicy; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { } failure:^(AFHTTPRequestOperation *operation, NSError *error) { SRLogHTTPTransport(@"Clean disconnect failed. %@",error); @@ -198,77 +176,6 @@ - (void)abort:(id)connection } } -- (NSString *)sendQueryString:(id )connection - connectionData:(NSString *)connectionData { - - NSMutableString *queryStringBuilder = [NSMutableString string]; - [queryStringBuilder appendFormat:@"?transport=%@",[self name]]; - [queryStringBuilder appendFormat:@"&connectionData=%@",SREscapeData(connectionData)]; - [queryStringBuilder appendFormat:@"&connectionToken=%@",SREscapeData(connection.connectionToken)]; - - NSString *customQuery = connection.queryString; - - if (customQuery != nil && ![customQuery isEqualToString:@""]) { - [queryStringBuilder appendFormat:@"&%@",customQuery]; - } - return queryStringBuilder; -} - -- (NSString *)receiveQueryString:(id )connection - data:(NSString *)data { - - NSMutableString *queryStringBuilder = [NSMutableString string]; - [queryStringBuilder appendFormat:@"?transport=%@",[self name]]; - [queryStringBuilder appendFormat:@"&connectionToken=%@",SREscapeData(connection.connectionToken)]; - - if(connection.messageId) { - [queryStringBuilder appendFormat:@"&messageId=%@",SREscapeData(connection.messageId)]; - } - - if (connection.groupsToken != nil) { - [queryStringBuilder appendFormat:@"&groupsToken=%@",SREscapeData(connection.groupsToken)]; - } - - if (data != nil) { - [queryStringBuilder appendFormat:@"&connectionData=%@",SREscapeData(data)]; - } - - NSString *customQuery = connection.queryString; - - if (customQuery != nil && ![customQuery isEqualToString:@""]) { - [queryStringBuilder appendFormat:@"&%@",customQuery]; - } - - return queryStringBuilder; -} - -- (NSString *)appendBaseUrl:(NSString *)baseUrl - withConnectionQueryString:(id )connection { - - if (baseUrl == nil) { - baseUrl = @""; - } - - NSString *queryString = @""; - - if (connection.queryString != nil && ![connection.queryString isEqualToString:@""]) { - NSString *appender = @""; - // If the custom query string already starts with an ampersand or question mark - // then we dont have to use any appender, it can be empty. - if (![connection.queryString hasPrefix:@"?"] && ![connection.queryString hasPrefix:@"&"]) { - appender = @"?"; - - if ([baseUrl rangeOfString:appender options:NSCaseInsensitiveSearch].location != NSNotFound) { - appender = @"&"; - } - } - - queryString = [[queryString stringByAppendingString:appender] stringByAppendingString:connection.queryString]; - } - - return queryString; -} - - (void)processResponse:(id )connection response:(NSString *)response shouldReconnect:(BOOL *)shouldReconnect diff --git a/SignalR.Client/Transports/SRLongPollingTransport.m b/SignalR.Client/Transports/SRLongPollingTransport.m index 20b4b79c..d372f9e2 100644 --- a/SignalR.Client/Transports/SRLongPollingTransport.m +++ b/SignalR.Client/Transports/SRLongPollingTransport.m @@ -20,7 +20,7 @@ // DEALINGS IN THE SOFTWARE. // -#import "AFHTTPRequestOperation.h" +#import #import "SRConnectionInterface.h" #import "SRConnectionExtensions.h" #import "SRExceptionHelper.h" @@ -91,20 +91,34 @@ - (void)poll:(id)connection connectionData:(NSString *)co } else { url = [url stringByAppendingString:@"poll"]; } - url = [url stringByAppendingString:[self receiveQueryString:connection data:connectionData]]; - - NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; - [urlRequest setHTTPMethod:@"GET"]; - [urlRequest setTimeoutInterval:240]; - - [connection prepareRequest:urlRequest]; [self delayConnectionReconnect:connection canReconnect:canReconnect]; __weak __typeof(&*self)weakSelf = self; __weak __typeof(&*connection)weakConnection = connection; - AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest]; + + id parameters = @{ + @"transport" : [self name], + @"connectionToken" : [connection connectionToken], + @"messageId" : ([connection messageId]) ? [connection messageId] : @"", + @"groupsToken" : ([connection groupsToken]) ? [connection groupsToken] : @"", + @"connectionData" : (connectionData) ? connectionData : @"", + }; + + if ([connection queryString]) { + NSMutableDictionary *_parameters = [NSMutableDictionary dictionaryWithDictionary:parameters]; + [_parameters addEntriesFromDictionary:[connection queryString]]; + parameters = _parameters; + } + + NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:url parameters:parameters error:nil]; + [request setTimeoutInterval:240]; + //TODO: prepareRequest + AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; + //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + //operation.credential = self.credential; + //operation.securityPolicy = self.securityPolicy; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { __strong __typeof(&*weakSelf)strongSelf = weakSelf; __strong __typeof(&*weakConnection)strongConnection = weakConnection; diff --git a/SignalR.Client/Transports/SRServerSentEventsTransport.m b/SignalR.Client/Transports/SRServerSentEventsTransport.m index 187a2a9d..31827984 100644 --- a/SignalR.Client/Transports/SRServerSentEventsTransport.m +++ b/SignalR.Client/Transports/SRServerSentEventsTransport.m @@ -20,7 +20,7 @@ // DEALINGS IN THE SOFTWARE. // -#import "AFHTTPRequestOperation.h" +#import #import "SRServerSentEventsTransport.h" #import "SRConnectionInterface.h" #import "SREventSourceStreamReader.h" @@ -121,20 +121,32 @@ - (void)lostConnection:(id)connection { - (void)open:(id )connection connectionData:(NSString *)connectionData { BOOL reconnecting = self.completionHandler == nil; - NSString *url = (reconnecting) ? connection.url : [connection.url stringByAppendingString:@"connect"]; - url = [url stringByAppendingString:[self receiveQueryString:connection data:connectionData]]; - - NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]]; - [urlRequest setHTTPMethod:@"GET"]; - [urlRequest setValue:@"text/event-stream" forHTTPHeaderField:@"Accept"]; - [urlRequest setValue:@"Keep-Alive" forHTTPHeaderField:@"Connection"]; - [urlRequest setTimeoutInterval:240]; + __block SREventSourceStreamReader *eventSource; + id parameters = @{ + @"transport" : [self name], + @"connectionToken" : [connection connectionToken], + @"messageId" : ([connection messageId]) ? [connection messageId] : @"", + @"groupsToken" : ([connection groupsToken]) ? [connection groupsToken] : @"", + @"connectionData" : (connectionData) ? connectionData : @"", + }; - [connection prepareRequest:urlRequest]; + if ([connection queryString]) { + NSMutableDictionary *_parameters = [NSMutableDictionary dictionaryWithDictionary:parameters]; + [_parameters addEntriesFromDictionary:[connection queryString]]; + parameters = _parameters; + } - __block SREventSourceStreamReader *eventSource; - SRHTTPRequestOperation *operation = [[SRHTTPRequestOperation alloc] initWithRequest:urlRequest]; + NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[connection.url stringByAppendingString:@"connect"] parameters:parameters error:nil]; + [request setTimeoutInterval:240]; + //TODO: Use ResponseSerializer for this... + [request setValue:@"text/event-stream" forHTTPHeaderField:@"Accept"]; + [request setValue:@"Keep-Alive" forHTTPHeaderField:@"Connection"]; + //TODO: prepareRequest + SRHTTPRequestOperation *operation = [[SRHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; + //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; + //operation.credential = self.credential; + //operation.securityPolicy = self.securityPolicy; [operation setDidReceiveResponseBlock:^(AFHTTPRequestOperation *operation, NSHTTPURLResponse *response) { eventSource = [[SREventSourceStreamReader alloc] initWithStream:operation.outputStream]; __weak __typeof(&*self)weakSelf = self; diff --git a/SignalR.Client/Transports/SRWebSocketTransport.m b/SignalR.Client/Transports/SRWebSocketTransport.m index 566acae9..fcd5b936 100644 --- a/SignalR.Client/Transports/SRWebSocketTransport.m +++ b/SignalR.Client/Transports/SRWebSocketTransport.m @@ -20,8 +20,9 @@ // DEALINGS IN THE SOFTWARE. // +#import +#import #import "SRWebSocketTransport.h" -#import "SRWebSocket.h" #import "SRLog.h" #import "SRWebSocketConnectionInfo.h" #import "SRConnectionInterface.h" @@ -94,18 +95,29 @@ - (void)performConnect:(void (^)(id response, NSError *error))block { } - (void)performConnect:(void (^)(id response, NSError *error))block reconnecting:(BOOL)reconnecting { - NSString *urlString = [_connectionInfo.connection.url stringByAppendingString:reconnecting ? @"reconnect" : @"connect"]; - urlString = [urlString stringByAppendingString:[self receiveQueryString:_connectionInfo.connection data:_connectionInfo.data]]; - - NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]]; - [_connectionInfo.connection prepareRequest:urlRequest]; + id parameters = @{ + @"transport" : [self name], + @"connectionToken" : [[_connectionInfo connection] connectionToken], + @"messageId" : ([[_connectionInfo connection] messageId]) ? [[_connectionInfo connection] messageId] : @"", + @"groupsToken" : ([[_connectionInfo connection] groupsToken]) ? [[_connectionInfo connection] groupsToken] : @"", + @"connectionData" : ([_connectionInfo data]) ? [_connectionInfo data] : @"", + }; + + if ([[_connectionInfo connection] queryString]) { + NSMutableDictionary *_parameters = [NSMutableDictionary dictionaryWithDictionary:parameters]; + [_parameters addEntriesFromDictionary:[[_connectionInfo connection] queryString]]; + parameters = _parameters; + } + + NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[_connectionInfo.connection.url stringByAppendingString:reconnecting ? @"reconnect" : @"connect"] parameters:parameters error:nil]; + //TODO: prepareRequest - SRLogWebSocket(@"WS: %@",[urlRequest.URL absoluteString]); + SRLogWebSockets(@"WS: %@",[request.URL absoluteString]); [self setStartBlock:block]; - _webSocket = [[SRWebSocket alloc] initWithURLRequest:urlRequest]; + _webSocket = [[SRWebSocket alloc] initWithURLRequest:request]; [_webSocket setDelegate:self]; [_webSocket open]; } @@ -114,7 +126,7 @@ - (void)performConnect:(void (^)(id response, NSError *error))block reconnecting #pragma mark SRWebSocketDelegate - (void)webSocketDidOpen:(SRWebSocket *)webSocket { - SRLogWebSocket(@"Websocket Connected"); + SRLogWebSockets(@"Websocket Connected"); // This will noop if we're not in the reconnecting state if ([[_connectionInfo connection] changeState:reconnecting toState:connected]) { @@ -123,7 +135,7 @@ - (void)webSocketDidOpen:(SRWebSocket *)webSocket { } - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message { - SRLogWebSocket(@"WS Receive: %@", message); + SRLogWebSockets(@"WS Receive: %@", message); BOOL timedOut = NO; BOOL disconnected = NO; @@ -141,7 +153,7 @@ - (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message { } - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error { - SRLogWebSocket(@"Websocket Failed With Error %@, %@", [[_connectionInfo connection] connectionId], error); + SRLogWebSockets(@"Websocket Failed With Error %@, %@", [[_connectionInfo connection] connectionId], error); if (self.startBlock) { self.startBlock(nil,error); @@ -156,7 +168,7 @@ - (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error { } - (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean { - SRLogWebSocket(@"WebSocket closed"); + SRLogWebSockets(@"WebSocket closed"); if ([self tryCompleteAbort]) { return; diff --git a/SignalR.Client/Transports/ServerSentEvents/SREventSourceStreamReader.h b/SignalR.Client/Transports/ServerSentEvents/SREventSourceStreamReader.h index 787384ff..fecc3d4b 100644 --- a/SignalR.Client/Transports/ServerSentEvents/SREventSourceStreamReader.h +++ b/SignalR.Client/Transports/ServerSentEvents/SREventSourceStreamReader.h @@ -24,26 +24,26 @@ @class SRServerSentEvent; -typedef void (^onStreamOpened)(); -typedef void (^onStreamClosed)(NSError * error); -typedef void (^onStreamMessage)(SRServerSentEvent * event); +typedef void (^SREventSourceStreamReaderStreamOpenedBlock)(); +typedef void (^SREventSourceStreamReaderStreamClosedBlock)(NSError * error); +typedef void (^SREventSourceStreamReaderStreamMessageBlock)(SRServerSentEvent * event); @interface SREventSourceStreamReader : NSObject /* * Invoked when the connection is open. */ -@property (copy) onStreamOpened opened; +@property (copy) SREventSourceStreamReaderStreamOpenedBlock opened; /* * Invoked when the reader is closed while in the Processing state. */ -@property (copy) onStreamClosed closed; +@property (copy) SREventSourceStreamReaderStreamClosedBlock closed; /* * Invoked when there's a message if received in the stream. */ -@property (copy) onStreamMessage message; +@property (copy) SREventSourceStreamReaderStreamMessageBlock message; - (id)initWithStream:(NSOutputStream *)steam; From 3d3008f066d2af8dd7718a4551b3725a0baf40ab Mon Sep 17 00:00:00 2001 From: Colin Swelin Date: Mon, 17 Mar 2014 13:28:00 -0400 Subject: [PATCH 5/7] web socket abort crash Fixes crash when calling connection stop on a web socket transport. --- SignalR.Client/Transports/SRWebSocketTransport.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SignalR.Client/Transports/SRWebSocketTransport.m b/SignalR.Client/Transports/SRWebSocketTransport.m index fcd5b936..404cb69c 100644 --- a/SignalR.Client/Transports/SRWebSocketTransport.m +++ b/SignalR.Client/Transports/SRWebSocketTransport.m @@ -75,7 +75,7 @@ - (void)send:(id)connection data:(NSString *)data connect } } -- (void)abort:(id )connection timeout:(NSNumber *)timeout { +- (void)abort:(id )connection timeout:(NSNumber *)timeout connectionData:(NSString *)connectionData { [_webSocket setDelegate:nil]; [_webSocket close]; _webSocket = nil; From a2d145c7dd48df7938cfae1b98135d2e3264a5a1 Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Mon, 14 Apr 2014 15:47:09 -0400 Subject: [PATCH 6/7] Prepare Request so the headers are properly set. Eventually this should be done by a request serializer per AFNetworking conventions --- .../project.pbxproj | 23 +++++++++++-------- .../Transports/SRHttpBasedTransport.m | 6 ++--- .../Transports/SRLongPollingTransport.m | 2 +- .../Transports/SRServerSentEventsTransport.m | 2 +- .../Transports/SRWebSocketTransport.m | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj b/SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj index d8da9a2e..113ee3bc 100644 --- a/SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj +++ b/SignalR.Client.ObjC/SignalR.Client.ObjC.xcodeproj/project.pbxproj @@ -941,7 +941,7 @@ 392077FE15AF13C3009B959E /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0460; + LastUpgradeCheck = 0510; ORGANIZATIONNAME = "DyKnow LLC"; }; buildConfigurationList = 3920780115AF13C3009B959E /* Build configuration list for PBXProject "SignalR.Client.ObjC" */; @@ -1296,7 +1296,7 @@ 3919635F15AF1EC200DDC946 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"", @@ -1319,7 +1319,7 @@ 3919636015AF1EC200DDC946 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; + COMBINE_HIDPI_IMAGES = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1343,7 +1343,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = E1168910CBED44F49353CF85 /* Pods-SignalR.Client.OSX.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "\"$(SYSTEM_APPS_DIR)/Xcode.app/Contents/Developer/Library/Frameworks\"", @@ -1375,7 +1374,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = E1168910CBED44F49353CF85 /* Pods-SignalR.Client.OSX.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -1422,9 +1420,10 @@ buildSettings = { ADDITIONAL_SDKS = ""; ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -1438,11 +1437,15 @@ ); GCC_SYMBOLS_PRIVATE_EXTERN = NO; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.0; MACOSX_DEPLOYMENT_TARGET = 10.8; + ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; }; name = Debug; @@ -1452,17 +1455,21 @@ buildSettings = { ADDITIONAL_SDKS = ""; ALWAYS_SEARCH_USER_PATHS = NO; - ARCHS = "$(ARCHS_STANDARD_32_BIT)"; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNDECLARED_SELECTOR = YES; GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; IPHONEOS_DEPLOYMENT_TARGET = 6.0; MACOSX_DEPLOYMENT_TARGET = 10.8; @@ -1536,7 +1543,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 28CD7529FF074ADAAD285BB4 /* Pods-SignalR.Client.Tests.OSX.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; @@ -1561,7 +1567,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = 28CD7529FF074ADAAD285BB4 /* Pods-SignalR.Client.Tests.OSX.xcconfig */; buildSettings = { - ARCHS = "$(ARCHS_STANDARD_64_BIT)"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; diff --git a/SignalR.Client/Transports/SRHttpBasedTransport.m b/SignalR.Client/Transports/SRHttpBasedTransport.m index 4c8e37f4..7d03619e 100644 --- a/SignalR.Client/Transports/SRHttpBasedTransport.m +++ b/SignalR.Client/Transports/SRHttpBasedTransport.m @@ -61,8 +61,8 @@ - (void)negotiate:(id)connection connectionData:(NSString } NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[connection.url stringByAppendingString:@"negotiate"] parameters:parameters error:nil]; + [connection prepareRequest:request]; //TODO: prepareRequest [request setTimeoutInterval:30]; - //TODO: prepareRequest AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; @@ -100,7 +100,7 @@ - (void)send:(id)connection data:(NSString *)data connect //So we let AFNetworking Generate our URL with proper encoding and then create the POST url which will encode the data in the body. NSMutableURLRequest *url = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[connection.url stringByAppendingString:@"send"] parameters:parameters error:nil]; NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:[[url URL] absoluteString] parameters:@{ @"data" : data } error:nil]; - //TODO: prepareRequest + [connection prepareRequest:request]; //TODO: prepareRequest AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; @@ -160,8 +160,8 @@ - (void)abort:(id)connection timeout:(NSNumber *)timeout NSMutableURLRequest *url = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[connection.url stringByAppendingString:@"abort"] parameters:parameters error:nil]; NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"POST" URLString:[[url URL] absoluteString] parameters:nil error:nil]; + [connection prepareRequest:request]; //TODO: prepareRequest [request setTimeoutInterval:2]; - //TODO: prepareRequest AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; diff --git a/SignalR.Client/Transports/SRLongPollingTransport.m b/SignalR.Client/Transports/SRLongPollingTransport.m index d372f9e2..deb3b2a1 100644 --- a/SignalR.Client/Transports/SRLongPollingTransport.m +++ b/SignalR.Client/Transports/SRLongPollingTransport.m @@ -112,8 +112,8 @@ - (void)poll:(id)connection connectionData:(NSString *)co } NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:url parameters:parameters error:nil]; + [connection prepareRequest:request]; //TODO: prepareRequest [request setTimeoutInterval:240]; - //TODO: prepareRequest AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; [operation setResponseSerializer:[AFJSONResponseSerializer serializer]]; //operation.shouldUseCredentialStorage = self.shouldUseCredentialStorage; diff --git a/SignalR.Client/Transports/SRServerSentEventsTransport.m b/SignalR.Client/Transports/SRServerSentEventsTransport.m index 31827984..344775e1 100644 --- a/SignalR.Client/Transports/SRServerSentEventsTransport.m +++ b/SignalR.Client/Transports/SRServerSentEventsTransport.m @@ -137,8 +137,8 @@ - (void)open:(id )connection connectionData:(NSString *)c } NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[connection.url stringByAppendingString:@"connect"] parameters:parameters error:nil]; + [connection prepareRequest:request]; //TODO: prepareRequest [request setTimeoutInterval:240]; - //TODO: Use ResponseSerializer for this... [request setValue:@"text/event-stream" forHTTPHeaderField:@"Accept"]; [request setValue:@"Keep-Alive" forHTTPHeaderField:@"Connection"]; //TODO: prepareRequest diff --git a/SignalR.Client/Transports/SRWebSocketTransport.m b/SignalR.Client/Transports/SRWebSocketTransport.m index 404cb69c..963f36c0 100644 --- a/SignalR.Client/Transports/SRWebSocketTransport.m +++ b/SignalR.Client/Transports/SRWebSocketTransport.m @@ -111,7 +111,7 @@ - (void)performConnect:(void (^)(id response, NSError *error))block reconnecting } NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] requestWithMethod:@"GET" URLString:[_connectionInfo.connection.url stringByAppendingString:reconnecting ? @"reconnect" : @"connect"] parameters:parameters error:nil]; - //TODO: prepareRequest + [_connectionInfo.connection prepareRequest:request]; //TODO: prepareRequest SRLogWebSockets(@"WS: %@",[request.URL absoluteString]); From 704ea8b62d8b1c87a5126b6073f0476d745e1887 Mon Sep 17 00:00:00 2001 From: Alex Billingsley Date: Mon, 25 Aug 2014 15:12:32 -0400 Subject: [PATCH 7/7] Report Errors when negotiate fails --- SignalR.Client/SRConnection.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SignalR.Client/SRConnection.m b/SignalR.Client/SRConnection.m index db039eba..4c5b9aec 100644 --- a/SignalR.Client/SRConnection.m +++ b/SignalR.Client/SRConnection.m @@ -133,8 +133,8 @@ - (void)negotiate:(id)transport { __weak __typeof(&*self)weakSelf = self; [transport negotiate:self connectionData:_connectionData completionHandler:^(SRNegotiationResponse *negotiationResponse, NSError *error) { + __strong __typeof(&*weakSelf)strongSelf = weakSelf; if (!error) { - __strong __typeof(&*weakSelf)strongSelf = weakSelf; SRLogConnection(@"negotiation was successful %@",negotiationResponse); [strongSelf verifyProtocolVersion:negotiationResponse.protocolVersion]; @@ -150,6 +150,10 @@ - (void)negotiate:(id)transport { } [strongSelf startTransport]; + } else { + SRLogConnection(@"negotiation failed %@", error); + + [strongSelf didReceiveError:error]; } }]; }