diff options
author | Jorge Canizales <jcanizales@google.com> | 2015-08-31 19:15:21 -0700 |
---|---|---|
committer | Jorge Canizales <jcanizales@google.com> | 2015-08-31 19:18:20 -0700 |
commit | 9fffc2618740111691454acaec65854c99027f53 (patch) | |
tree | 30928e4e4b1bf5ffd98e4a367e5a3d09aa2ceb3b /src | |
parent | d4a0785569c78486b0917a5fc949034fbb53dd01 (diff) |
Example with generated code :)
Diffstat (limited to 'src')
-rw-r--r-- | src/objective-c/examples/SwiftSample/Bridging-Header.h | 1 | ||||
-rw-r--r-- | src/objective-c/examples/SwiftSample/ViewController.swift | 20 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/objective-c/examples/SwiftSample/Bridging-Header.h b/src/objective-c/examples/SwiftSample/Bridging-Header.h index 3b2ae74d8b..33db2dd1cb 100644 --- a/src/objective-c/examples/SwiftSample/Bridging-Header.h +++ b/src/objective-c/examples/SwiftSample/Bridging-Header.h @@ -39,5 +39,6 @@ #import <RxLibrary/GRXWriter+Immediate.h> #import <GRPCClient/GRPCCall.h> #import <ProtoRPC/ProtoMethod.h> +#import <RemoteTest/Test.pbrpc.h> #endif diff --git a/src/objective-c/examples/SwiftSample/ViewController.swift b/src/objective-c/examples/SwiftSample/ViewController.swift index dedcce20e7..e4e7aeae49 100644 --- a/src/objective-c/examples/SwiftSample/ViewController.swift +++ b/src/objective-c/examples/SwiftSample/ViewController.swift @@ -40,17 +40,33 @@ class ViewController: UIViewController { let RemoteHost = "grpc-test.sandbox.google.com" + let request = RMTSimpleRequest() + request.responseSize = 10 + request.fillUsername = true + request.fillOauthScope = true + + // Example gRPC call using a generated proto client library: + + let service = RMTTestService(host: RemoteHost) + service.unaryCallWithRequest(request) { (response: RMTSimpleResponse?, error: NSError?) in + if let response = response { + NSLog("Finished successfully with response:\n\(response)") + } else { + NSLog("Finished with error: \(error!)") + } + } + // Same example call using the generic gRPC client library: let method = ProtoMethod(package: "grpc.testing", service: "TestService", method: "UnaryCall") - let requestsWriter = GRXWriter(value: NSData()) + let requestsWriter = GRXWriter(value: request.data()) let call = GRPCCall(host: RemoteHost, path: method.HTTPPath, requestsWriter: requestsWriter) let responsesWriteable = GRXWriteable { (value: AnyObject?, error: NSError?) in if let value = value as? NSData { - NSLog("Received response:\n\(value)") + NSLog("Received response:\n\(RMTSimpleResponse(data: value, error: nil))") } else { NSLog("Finished with error: \(error!)") } |