Skip to content

Missing an example project for grpc-web in client-side Swift #988

@imWildCat

Description

@imWildCat

What are you trying to achieve?

After grpc-web is supported (#350), there's no update for the example about using grpc-web in client-side Swift.

There's update for server-side Swift in that PR, I believe.

What have you tried so far?

Created a demo project locally trying to set up client-side grpc-swift.

  override func viewDidLoad() {

    super.viewDidLoad()

    let client = Greet_GreeterClient(channel: setupChannel())

    var hellpRequest = Greet_HelloRequest()
    hellpRequest.name = "demo"
    client.sayHello(hellpRequest).response.whenComplete { (result) in
      switch result {
      case .success(let reply):
        print("reply:", reply)
      case .failure(let error):
        print("error:", error)
      }
    }
  }

  func setupChannel() -> ClientConnection {
    let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
    let channel = ClientConnection.insecure(group: group) // This looks like grpc instead of grpc-web, right?
      .withBackgroundActivityLogger(self.clientLogger)
      .connect(host: "127.0.0.1", port: 5000)
    return channel
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/supportAdopter support requests.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions