-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnection.h
46 lines (37 loc) · 1.37 KB
/
Connection.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
44
45
46
#ifndef _CONNECTION_H
#define _CONNECTION_H
#include <string>
#include <grpc++/grpc++.h>
using grpc::Channel;
using grpc::ClientContext;
using grpc::Status;
class Connection {
public:
// Constuctor that sets up initial connection with the MinION
// mk_host: Host address of the MinKNOW to connect to
// mk_port: Port of MinKNOW to connect to
Connection(std::string mk_host="127.0.0.1", int mk_port=8000, int verbose=0){
host = mk_host;
port = mk_port;
// Creating channel arguments that set the max send and recieve message sizes
int max_send_receive_size = 16 * 1024 * 1024;
if(verbose) std::cerr << "Setting the max send and receive size to be: " << max_send_receive_size << std::endl;
grpc::ChannelArguments* channel_args = new grpc::ChannelArguments();
channel_args->SetMaxReceiveMessageSize(max_send_receive_size);
channel_args->SetMaxSendMessageSize(max_send_receive_size);
std::string target = host + ":" + std::to_string(port);
std::cerr << "Connecting on: " << target << std::endl;
// Create channel to connect to
channel = grpc::CreateCustomChannel(target, grpc::InsecureChannelCredentials(), *channel_args);
}
// Function to get created channel
// Returns the channel
std::shared_ptr<Channel> get_channel(){
return channel;
}
private:
std::string host;
int port;
std::shared_ptr<Channel> channel;
};
#endif