Demiurgic-JSON-RPC
Demiurgic-JSON-RPC copied to clipboard
Sync Process
Does it support Sync. process ? like calling a function that return a value from the service response and waiting the response to come back
-
(BOOL)checkUserExistence{ NSInteger callID;
_jsonRPCService =[[DSJSONRPC alloc] initWithServiceEndpoint:[NSURL URLWithString:@"http://serv.m-diet.com/Persons.ashx"]];
DSJSONRPCCompletionHandler completionHandler = ^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *internalError) { if (methodError) { NSLog(@"\nMethod %@(%i) returned an error: %@\n\n", methodName, callId, methodError); return NO; } else if (internalError) { NSLog(@"\nMethod %@(%i) couldn't be sent with error: %@\n\n", methodName, callId, internalError); return NO; } else { NSLog(@"\nMethod %@(%i) completed with result: %@\n\n", methodName, callId, methodResult); NSMutableDictionary *responceDictionary = (NSMutableDictionary *)methodResult; return [[responceDictionary objectForKey:@"result"]boolValue]; } };
callID = [_jsonRPCService callMethod:@"CheckPersonID" withParameters:@{ @"PersonID" : @"[email protected]"} onCompletion:completionHandler]; }
The API does not support synchronous communication. However, you should be able to get that behavior using dispatch semaphores.