rpcClient.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <iostream>
  3. #include <memory>
  4. #include <string>
  5. #include <conio.h>
  6. #include <grpcpp/grpcpp.h>
  7. #include <grpc/grpc.h>
  8. #include <grpc++/channel.h>
  9. #include <grpc++/client_context.h>
  10. #include <grpc++/create_channel.h>
  11. #include "../pb/protobuf.grpc.pb.h"
  12. #include "opencv2/opencv.hpp"
  13. using grpc::Status;
  14. using grpc::Channel;
  15. using grpc::ClientContext;
  16. using grpc::ClientWriter;
  17. using grpc::ClientReader;
  18. using grpc::ClientReaderWriter;
  19. using namespace_uploadpic::Request;
  20. using namespace_uploadpic::Response;
  21. using namespace namespace_uploadpic;
  22. using grpc::ClientContext;
  23. class VisionClient;
  24. class rpcClient
  25. {
  26. public:
  27. //构造函数,创建一个频道,用于指向服务器
  28. rpcClient(std::shared_ptr<Channel>channl) :stu_(upload_pic_servicer::NewStub(channl)) {}
  29. bool upload(cv::Mat img ,std::string user, std::string id );
  30. void ListFeatures();
  31. int getClientTime();
  32. int getServerTime();
  33. private:
  34. //这个是远程方法(API)的一个指针
  35. std::unique_ptr<upload_pic_servicer::Stub>stu_;
  36. int m_nClientTime = 0;
  37. int m_nServerTime = 0;
  38. };