推荐一个基于协程的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++处理文件上传的
相关推荐
金銀銅鐵2 小时前
用 Python 实现 Take-Away 游戏
python·游戏
金銀銅鐵19 小时前
用 Pygame 实现 15 puzzle
python·数学·游戏
clint4562 天前
C++进阶(1)——前景提要
c++
夜悊2 天前
C++代码示例:进制数简单生成工具
c++
郝学胜_神的一滴2 天前
CMake 021: IF 条件判据详诠
c++·cmake
_wyt0013 天前
洛谷 B3930 [GESP202312 五级] 烹饪问题 题解
c++·gesp
大树883 天前
金刚石散热越强,管路越先见顶
大数据·运维·服务器·人工智能·ai
小宇宙Zz3 天前
Maven依赖冲突
java·服务器·maven
玖玥拾3 天前
C/C++ 数据结构(七)栈、容器适配器
c语言·数据结构·c++··容器适配器
xingpanvip3 天前
星盘接口开发文档:本命盘接口指南
android·开发语言·css·php·lua