-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforwarding_service_impl.cpp
More file actions
32 lines (23 loc) · 1.04 KB
/
Copy pathforwarding_service_impl.cpp
File metadata and controls
32 lines (23 loc) · 1.04 KB
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 "src/forwarding_service_impl.hpp"
#include <grpcpp/grpcpp.h>
#include <iostream>
#include "common.hpp"
#include "proto/server_server.grpc.pb.h"
extern bool IS_VERBOSE;
using namespace std;
ForwardingServiceImpl::ForwardingServiceImpl(
shared_ptr<ServerState> state,
std::shared_ptr<ChatServiceImpl> chat_service)
: state{state}, chat_service{chat_service} {}
grpc::Status ForwardingServiceImpl::Forward(grpc::ServerContext *context,
const SS::ForwardedMessage *request,
client_server::Empty *response) {
log("Received forward from " + context->peer());
chat_service->handle_forwarded_message(request->message(),
request->sender_id(),
request->message().room(),
true);
log("Finished handling forwarded message from " + context->peer());
if (IS_VERBOSE) std::cout << *state;
return grpc::Status::OK;
}