blob: 1633aab8bacd73155382e46eff7bbfb2fc7b967f (
plain) (
blame)
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
|
#include "rpcStub.hpp"
class fossCordInternalsImpl final : public fosscordMedia::fosscordInternals::Service {
std::shared_ptr<rtcPeerHandler> ph;
fossCordInternalsImpl(std::shared_ptr<rtcPeerHandler> handler){
this->ph= handler;
}
grpc::Status vRequest(grpc::ServerContext* ctx,
const fosscordMedia::voiceRequest* req,
fosscordMedia::voiceAnswer* resp) override {
this->ph->initiateConnection(req->ip(), req->port());
return grpc::Status::OK;
}
};
rpcStub::rpcStub(std::shared_ptr<rtcPeerHandler> handler, int port) {
if (not port) {
port = 8057;
}
this->ph = handler;
fossCordInternalsImpl* service;
grpc::ServerBuilder builder;
builder.AddListeningPort("0.0.0.0:" + std::to_string(port),
grpc::InsecureServerCredentials());
builder.RegisterService(service);
this->server = builder.BuildAndStart();
std::cout << "RPC stub listening on port " << port << std::endl;
}
|