From a04344ec4193fabfb3c8488a3108ae06a8a620f4 Mon Sep 17 00:00:00 2001 From: Abbas Mousavi Date: Wed, 1 Jun 2016 17:58:44 +0430 Subject: [PATCH 1/8] Using AFHTTPSessionManager instead of AFHTTPRequestOperation --- AFJSONRPCClient/AFJSONRPCClient.h | 16 +++++----- AFJSONRPCClient/AFJSONRPCClient.m | 51 ++++++++++--------------------- 2 files changed, 24 insertions(+), 43 deletions(-) diff --git a/AFJSONRPCClient/AFJSONRPCClient.h b/AFJSONRPCClient/AFJSONRPCClient.h index d7086a5..1463845 100755 --- a/AFJSONRPCClient/AFJSONRPCClient.h +++ b/AFJSONRPCClient/AFJSONRPCClient.h @@ -21,14 +21,14 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "AFHTTPRequestOperationManager.h" +#import "AFHTTPSessionManager.h" /** AFJSONRPCClient objects communicate with web services using the JSON-RPC 2.0 protocol. @see http://www.jsonrpc.org/specification */ -@interface AFJSONRPCClient : AFHTTPRequestOperationManager +@interface AFJSONRPCClient : AFHTTPSessionManager /** The endpoint URL for the webservice. @@ -74,8 +74,8 @@ @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a two arguments: the request operation and the error describing the network or parsing error that occurred. */ - (void)invokeMethod:(NSString *)method - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; /** Creates a request with the specified method and parameters, and enqueues a request operation for it. @@ -87,8 +87,8 @@ */ - (void)invokeMethod:(NSString *)method withParameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; /** Creates a request with the specified method and parameters, and enqueues a request operation for it. @@ -102,8 +102,8 @@ - (void)invokeMethod:(NSString *)method withParameters:(id)parameters requestId:(id)requestId - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure; ///---------------------- /// @name Method Proxying diff --git a/AFJSONRPCClient/AFJSONRPCClient.m b/AFJSONRPCClient/AFJSONRPCClient.m index 1c98687..38b63a2 100755 --- a/AFJSONRPCClient/AFJSONRPCClient.m +++ b/AFJSONRPCClient/AFJSONRPCClient.m @@ -22,8 +22,6 @@ // THE SOFTWARE. #import "AFJSONRPCClient.h" -#import "AFHTTPRequestOperation.h" - #import NSString * const AFJSONRPCErrorDomain = @"com.alamofire.networking.json-rpc"; @@ -81,16 +79,16 @@ - (id)initWithEndpointURL:(NSURL *)URL { } - (void)invokeMethod:(NSString *)method - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure { [self invokeMethod:method withParameters:@[] success:success failure:failure]; } - (void)invokeMethod:(NSString *)method withParameters:(id)parameters - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure { [self invokeMethod:method withParameters:parameters requestId:@(1) success:success failure:failure]; } @@ -98,17 +96,8 @@ - (void)invokeMethod:(NSString *)method - (void)invokeMethod:(NSString *)method withParameters:(id)parameters requestId:(id)requestId - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - NSMutableURLRequest *request = [self requestWithMethod:method parameters:parameters requestId:requestId]; - AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithRequest:request success:success failure:failure]; - [self.operationQueue addOperation:operation]; -} - -- (NSMutableURLRequest *)requestWithMethod:(NSString *)method - parameters:(id)parameters - requestId:(id)requestId + success:(void (^)(NSURLSessionDataTask *task, id responseObject))success + failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure { NSParameterAssert(method); @@ -127,17 +116,8 @@ - (NSMutableURLRequest *)requestWithMethod:(NSString *)method payload[@"method"] = method; payload[@"params"] = parameters; payload[@"id"] = [requestId description]; - - return [self.requestSerializer requestWithMethod:@"POST" URLString:[self.endpointURL absoluteString] parameters:payload error:nil]; -} - -#pragma mark - AFHTTPClient - -- (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlRequest - success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success - failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure -{ - return [super HTTPRequestOperationWithRequest:urlRequest success:^(AFHTTPRequestOperation *operation, id responseObject) { + + [self POST:@"" parameters:payload success:^(NSURLSessionDataTask * _Nonnull task, id _Nonnull responseObject) { NSInteger code = 0; NSString *message = nil; id data = nil; @@ -148,7 +128,7 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR if (result && result != [NSNull null]) { if (success) { - success(operation, result); + success(task, result); return; } } else if (error && error != [NSNull null]) { @@ -185,12 +165,13 @@ - (AFHTTPRequestOperation *)HTTPRequestOperationWithRequest:(NSURLRequest *)urlR } NSError *error = [NSError errorWithDomain:AFJSONRPCErrorDomain code:code userInfo:userInfo]; - - failure(operation, error); + + failure(task, error); } - } failure:^(AFHTTPRequestOperation *operation, NSError *error) { + + } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { if (failure) { - failure(operation, error); + failure(task, error); } }]; } @@ -253,11 +234,11 @@ - (void)forwardInvocation:(NSInvocation *)invocation { __strong AFJSONRPCProxySuccessBlock strongSuccess = [unsafeSuccess copy]; __strong AFJSONRPCProxyFailureBlock strongFailure = [unsafeFailure copy]; - [self.client invokeMethod:RPCMethod withParameters:arguments success:^(__unused AFHTTPRequestOperation *operation, id responseObject) { + [self.client invokeMethod:RPCMethod withParameters:arguments success:^(__unused NSURLSessionDataTask *task, id responseObject) { if (strongSuccess) { strongSuccess(responseObject); } - } failure:^(__unused AFHTTPRequestOperation *operation, NSError *error) { + } failure:^(__unused NSURLSessionDataTask *task, NSError *error) { if (strongFailure) { strongFailure(error); } From 3a038906961b777ca0855540bcda06ebc1c3aa2f Mon Sep 17 00:00:00 2001 From: Abbas Mousavi Date: Wed, 1 Jun 2016 18:03:20 +0430 Subject: [PATCH 2/8] Changing deployment_target in podspec from 6.0 to 7.0 --- AFJSONRPCClient.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFJSONRPCClient.podspec b/AFJSONRPCClient.podspec index 36d3d3a..5050fc0 100644 --- a/AFJSONRPCClient.podspec +++ b/AFJSONRPCClient.podspec @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.source_files = 'AFJSONRPCClient' s.requires_arc = true - s.ios.deployment_target = '6.0' + s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.8' s.dependency 'AFNetworking', '~> 2.1' From e53bfe76763a41e172e713c5d79ca2d94450bcc0 Mon Sep 17 00:00:00 2001 From: Abbas Mousavi Date: Wed, 1 Jun 2016 18:07:59 +0430 Subject: [PATCH 3/8] Changing Mac deployment_target in podspec from 10.8 to 10.9 --- AFJSONRPCClient.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFJSONRPCClient.podspec b/AFJSONRPCClient.podspec index 5050fc0..d8302c2 100644 --- a/AFJSONRPCClient.podspec +++ b/AFJSONRPCClient.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.ios.deployment_target = '7.0' - s.osx.deployment_target = '10.8' + s.osx.deployment_target = '10.9' s.dependency 'AFNetworking', '~> 2.1' end From 973e0070c51aa18727652d483265ddab0341c9bf Mon Sep 17 00:00:00 2001 From: Abbas Mousavi Date: Sun, 5 Jun 2016 15:10:28 +0430 Subject: [PATCH 4/8] Updating dependendy to AFNetworking --- AFJSONRPCClient.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFJSONRPCClient.podspec b/AFJSONRPCClient.podspec index d8302c2..9f7685c 100644 --- a/AFJSONRPCClient.podspec +++ b/AFJSONRPCClient.podspec @@ -14,5 +14,5 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' - s.dependency 'AFNetworking', '~> 2.1' + s.dependency 'AFNetworking', '> 2.1' end From 7f671f54abb1895bb9e02e9fadec5776de4241f9 Mon Sep 17 00:00:00 2001 From: Abbas Mousavi Date: Mon, 22 Aug 2016 18:17:53 +0430 Subject: [PATCH 5/8] Using modular import --- AFJSONRPCClient/AFJSONRPCClient.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFJSONRPCClient/AFJSONRPCClient.h b/AFJSONRPCClient/AFJSONRPCClient.h index 1463845..1a8bd6e 100755 --- a/AFJSONRPCClient/AFJSONRPCClient.h +++ b/AFJSONRPCClient/AFJSONRPCClient.h @@ -21,7 +21,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -#import "AFHTTPSessionManager.h" +#import /** AFJSONRPCClient objects communicate with web services using the JSON-RPC 2.0 protocol. From e330fd274f15b318aedf034538a0c4d38a5667cb Mon Sep 17 00:00:00 2001 From: Abbas Mousavi Date: Sun, 11 Sep 2016 17:57:39 +0430 Subject: [PATCH 6/8] Adds watchOS support --- AFJSONRPCClient.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/AFJSONRPCClient.podspec b/AFJSONRPCClient.podspec index 9f7685c..8089434 100644 --- a/AFJSONRPCClient.podspec +++ b/AFJSONRPCClient.podspec @@ -13,6 +13,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' + s.watchos.deployment_target = '2.0' s.dependency 'AFNetworking', '> 2.1' end From 3ce4aab49138f6517371eee11e807c824f077172 Mon Sep 17 00:00:00 2001 From: Abbas Mousavi Date: Sat, 17 Sep 2016 17:09:25 +0430 Subject: [PATCH 7/8] adding tvOS support --- AFJSONRPCClient.podspec | 1 + 1 file changed, 1 insertion(+) diff --git a/AFJSONRPCClient.podspec b/AFJSONRPCClient.podspec index 8089434..09e7a65 100644 --- a/AFJSONRPCClient.podspec +++ b/AFJSONRPCClient.podspec @@ -14,6 +14,7 @@ Pod::Spec.new do |s| s.ios.deployment_target = '7.0' s.osx.deployment_target = '10.9' s.watchos.deployment_target = '2.0' + s.tvos.deployment_target = '9.0' s.dependency 'AFNetworking', '> 2.1' end From da8ae50cf2b8023b099dc97d3e83ca0c9652230d Mon Sep 17 00:00:00 2001 From: Abbas Mousavi Date: Mon, 12 Dec 2016 12:42:51 +0330 Subject: [PATCH 8/8] =?UTF-8?q?Changing=20AFNetworking=20dependacy=20to=20?= =?UTF-8?q?=E2=80=98~>=203.0=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AFJSONRPCClient.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AFJSONRPCClient.podspec b/AFJSONRPCClient.podspec index 09e7a65..54d1240 100644 --- a/AFJSONRPCClient.podspec +++ b/AFJSONRPCClient.podspec @@ -16,5 +16,5 @@ Pod::Spec.new do |s| s.watchos.deployment_target = '2.0' s.tvos.deployment_target = '9.0' - s.dependency 'AFNetworking', '> 2.1' + s.dependency 'AFNetworking', '~> 3.0' end