推荐一个基于协程的C++(lua)游戏服务器

1.跨平台

支持win,mac,linux等多个操作系统

2.协程系统

使用汇编实现的上下文模块,C++模块实现的协程调度器,使用共享栈,支持开启上千万协程,一个协程大概使用2000字节

3.rpc系统

强大的rpc系统,功能模块可以使用c++或者lua实现,也可以使用lua替换c++业务逻辑,rpc网络协议支持(tcp,udp,kcp)等

cpp 复制代码
Server * targetServer = this->GetActor();
const static std::string func("MongoDB.FindOne");
if(targetServer == nullptr)
{
	return nullptr;
}
std::unique_ptr<db::mongo::find_one::response> result
			= std::make_unique<db::mongo::find_one::response>();
int code = targetServer->Call(func, request, result.get());

code是错误码,request是请求参数,result是rpc返回的具体数据,内部有协程会自动挂起和唤醒

4.web网站

实现了一套http系统,支持静态网页,只需要配置一个路径即可,支持处理各种http请求,http请求支持c++或者lua处理,也可以使用lua替换c++逻辑

cpp 复制代码
int FileUpload::File(const http::Request &request, http::Response &response)
{
	int userId = 0;
	const http::Content* data = request.GetBody();
	request.GetUrl().GetQuery().Get(http::query::UserId, userId);
	const http::MultipartFromContent* multiData = data->To<const http::MultipartFromContent>();
	if (multiData == nullptr)
	{
		return XCode::CallArgsError;
	}
	if (!multiData->IsDone())
	{
		return XCode::CallArgsError;
	}
	const std::string & path = multiData->Path();
	const std::string& name = multiData->FileName();
	const std::string url = fmt::format("{}/{}", this->mDoMain, name);
	response.SetContent(http::Header::TEXT, url);
	return XCode::Ok;
}
这是一个使用c++处理文件上传的
相关推荐
用户8055336980311 小时前
不止三件套:QObject 属性系统全关键字与运行时反射!
c++·qt
BadBadBad__AK1 天前
线段树维护区间 k 次方和
c++·数学·算法·stl
金銀銅鐵1 天前
[Python] 模 n 乘法的逆元计算器
python·数学·游戏
卷无止境1 天前
Eigen 库如何借助 OpenMP 加速计算
c++·后端
卷无止境1 天前
OpenMPI、MPICH 与 OpenMP:关系、核心概念与架构全解
c++·后端
金銀銅鐵2 天前
借助 Pygame 探索最大公约数的规律
python·数学·游戏
郝学胜_神的一滴2 天前
CMake 30:循环语法全解|foreach_while双循环精讲、迭代技巧与实战避坑指南
c++·cmake
卷无止境4 天前
C++ 的Eigen 库全解析
c++
卷无止境4 天前
现代 C++特性大盘点:一门脱胎换骨的老语言
c++·后端
郝学胜_神的一滴4 天前
CMake 27:缓存变量的特性、语法、类型与实操全解
c++·cmake