-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.cpp
More file actions
49 lines (35 loc) · 1.41 KB
/
server.cpp
File metadata and controls
49 lines (35 loc) · 1.41 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// server.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include "grpc++/grpc++.h"
#include "protos/client.grpc.pb.h"
class Server : public window::Window::Service {
public:
Server() {}
virtual ::grpc::Status MoveWindow(::grpc::ServerContext* context, const ::window::MoveMessage* request, ::window::ResponseMessage* response) override {
HWND win = (HWND)request->hwnd();
auto left = request->left();
auto top = request->top();
auto width = request->width();
auto height = request->height();
auto repaint = request->repaint();
std::cout << "MoveWindow: " << win << ", " << left << ", " << top << ", " << width << ", " << height << std::endl;
::MoveWindow(win, left, top, width, height, repaint);
response->set_result(1000);
std::cout << "Move Ending." << std::endl;
return grpc::Status::OK;
}
};
int main() {
std::cout << "Hello World!\n";
std::string address("0.0.0.0:50051");
std::cout << "server listening on: " << address << "\n";
Server server;
grpc::ServerBuilder builder;
builder.AddListeningPort(address, grpc::InsecureServerCredentials());
builder.RegisterService(&server);
std::unique_ptr<grpc::Server> grpc_server(builder.BuildAndStart());
std::cout << "server on ..." << std::endl;
grpc_server->Wait();
return 0;
}