mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
43 lines
1022 B
C++
43 lines
1022 B
C++
#pragma once
|
|
|
|
#ifndef NKR_NO_GRPC
|
|
|
|
#include "go/gen/libcore.pb.h"
|
|
#include <QString>
|
|
|
|
namespace QtGrpc {
|
|
class Http2GrpcChannelPrivate;
|
|
}
|
|
|
|
namespace NekoRay::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::unique_ptr<QtGrpc::Http2GrpcChannelPrivate> grpc_channel;
|
|
std::function<void(const QString &)> onError;
|
|
};
|
|
|
|
inline Client *defaultClient;
|
|
} // namespace NekoRay::rpc
|
|
#endif
|