1 #ifndef ORDERSSTREAMSERVICE_H
2 #define ORDERSSTREAMSERVICE_H
5 #include "customservice.h"
6 #include <grpcpp/grpcpp.h>
7 #include "orders.grpc.pb.h"
8 #include "servicereply.h"
10 using grpc::ClientAsyncReader;
12 using grpc::CompletionQueue;
14 using namespace tinkoff::public_::invest::api::contract::v1;
25 OrdersStream(std::shared_ptr<Channel> channel,
const std::string &token);
29 void TradesStream(
const std::vector<std::string> &accounts, std::function<
void(
ServiceReply)> callback);
31 void TradesStreamAsync(
const std::vector<std::string> &accounts, std::function<
void(
ServiceReply)> callback);
32 void AsyncCompleteRpc();
40 AsyncClientCall(
const TradesStreamRequest& request, CompletionQueue& cq_, std::unique_ptr<OrdersStreamService::Stub>& stub_, std::string token, std::function<
void(
ServiceReply)> callback);
43 ClientContext context;
44 TradesStreamResponse reply;
45 enum CallStatus {CREATE, PROCESS, FINISH};
46 CallStatus callStatus;
49 void Proceed(
bool ok =
true);
52 std::unique_ptr<ClientAsyncReader<TradesStreamResponse> > responder;
57 std::unique_ptr<OrdersStreamService::Stub> m_ordersStreamService;
58 std::unique_ptr<std::thread> m_grpcThread;
63 #endif // ORDERSSTREAMSERVICE_H