-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathexample.cpp
30 lines (29 loc) · 1.2 KB
/
example.cpp
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
#include "proxy.h"
#include <chrono>
#include <thread>
int main() {
//创建一个代理对象
Proxy *proxy = new Proxy(false,"0.0.0.0",25565,false,"mc.hypixel.net",25565);
//设置代理的回调函数
//各个回调函数的参数及作用请查看proxy.h或利用IDE的转到定义功能查看
proxy->on_connected += [](const RbsLib::Network::TCP::TCPConnection& client) {
std::cout << "Client connected: " << client.GetAddress() << std::endl;
};
proxy->on_disconnect += [](const RbsLib::Network::TCP::TCPConnection& client) {
std::cout << "Client disconnected: " << client.GetAddress() << std::endl;
};
proxy->on_login += [](const RbsLib::Network::TCP::TCPConnection& client, const std::string& username, const std::string& uuid) {
std::cout << "Client logged in: " << client.GetAddress() << " as " << username << " with UUID " << uuid << std::endl;
};
proxy->on_logout += [](const RbsLib::Network::TCP::TCPConnection& client,const UserInfo&user) {
std::cout << "Client logged out: " << client.GetAddress() << " as " << user.username << " with UUID " << user.uuid << std::endl;
};
//设置最大玩家数量
proxy->SetMaxPlayer(100);
//启动代理
proxy->Start();
while (true) {
std::this_thread::sleep_for(std::chrono::seconds(1));
}
return 0;
}