]> git.sesse.net Git - stockfish/blobdiff - src/client.cc
Initial commit for gRPC code.
[stockfish] / src / client.cc
diff --git a/src/client.cc b/src/client.cc
new file mode 100644 (file)
index 0000000..05fe597
--- /dev/null
@@ -0,0 +1,33 @@
+#include <iostream>
+#include <memory>
+#include <string>
+
+#include <grpc++/grpc++.h>
+
+#include "hashprobe.grpc.pb.h"
+
+using grpc::Channel;
+using grpc::ClientContext;
+using grpc::Status;
+
+int main(int argc, char** argv) {
+  std::shared_ptr<Channel> channel(grpc::CreateChannel(
+      "localhost:50051", grpc::InsecureChannelCredentials()));
+  std::unique_ptr<HashProbe::Stub> stub(HashProbe::NewStub(channel));
+
+  HashProbeRequest request;
+//  request.set_fen("rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1");
+  request.set_fen(argv[1]);
+
+  HashProbeResponse response;
+  ClientContext context;
+  Status status = stub->Probe(&context, request, &response);
+
+  if (status.ok()) {
+    std::cout << response.DebugString();
+  } else {
+    std::cout << "RPC failed";
+  }
+
+  return 0;
+}