-
Notifications
You must be signed in to change notification settings - Fork 21
/
service.hpp
55 lines (46 loc) · 1.52 KB
/
service.hpp
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
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef __SERVICE_HPP__
#define __SERVICE_HPP__
#include <iostream>
#include <sstream>
#include <vector>
#include <libtorrent/libtorrent.hpp>
#include <grpc++/grpc++.h>
#include "ezio.grpc.pb.h"
using grpc::Server;
using grpc::ServerBuilder;
using grpc::ServerContext;
using grpc::Status;
using ezio::Empty;
using ezio::Torrent;
using ezio::AddRequest;
using ezio::AddResponse;
using ezio::UpdateRequest;
using ezio::UpdateStatus;
using ezio::PauseTorrentRequest;
using ezio::PauseTorrentResponse;
using ezio::ResumeTorrentRequest;
using ezio::ResumeTorrentResponse;
using ezio::EZIO;
namespace ezio
{
class ezio;
class gRPCService final : public EZIO::Service
{
public:
gRPCService(ezio &);
explicit gRPCService();
void start(std::string);
void stop();
void wait();
virtual Status Shutdown(ServerContext *context, const Empty *e1, Empty *e2) override;
virtual Status GetTorrentStatus(ServerContext *context, const UpdateRequest *request, UpdateStatus *response) override;
virtual Status AddTorrent(ServerContext *context, const AddRequest *request, AddResponse *response) override;
virtual Status PauseTorrent(ServerContext *context, const PauseTorrentRequest *request, PauseTorrentResponse *response) override;
virtual Status ResumeTorrent(ServerContext *context, const ResumeTorrentRequest *request, ResumeTorrentResponse *response) override;
virtual Status GetVersion(ServerContext *context, const Empty *e, VersionResponse *response) override;
private:
ezio &daemon_;
std::unique_ptr<Server> server_;
};
} // namespace ezio
#endif