forked from MatsuriDayo/nekoray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgRPC.h
43 lines (28 loc) · 1.11 KB
/
gRPC.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
#ifndef NKR_NO_GRPC
#include "go/grpc_server/gen/libcore.pb.h"
#include <QString>
namespace QtGrpc {
class Http2GrpcChannelPrivate;
}
namespace NekoGui_rpc {
class Client {
public:
explicit Client(std::function<void(const QString &)> onError, const QString &target, const QString &token);
void Exit();
bool KeepAlive();
// QString returns is error string
QString Start(bool *rpcOK, const libcore::LoadConfigReq &request);
QString Stop(bool *rpcOK);
long long QueryStats(const std::string &tag, const std::string &direct);
std::string ListConnections();
libcore::TestResp Test(bool *rpcOK, const libcore::TestReq &request);
libcore::UpdateResp Update(bool *rpcOK, const libcore::UpdateReq &request);
private:
std::function<std::unique_ptr<QtGrpc::Http2GrpcChannelPrivate>()> make_grpc_channel;
std::unique_ptr<QtGrpc::Http2GrpcChannelPrivate> default_grpc_channel;
std::function<void(const QString &)> onError;
};
inline Client *defaultClient;
} // namespace NekoGui_rpc
#endif