推荐一个基于协程的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++处理文件上传的
相关推荐
博客18009 小时前
酷宝的使用方法,超好用的免费界面库,C++、MFC可用
c++·mfc·界面库·库来帮·酷宝
郝学胜_神的一滴10 小时前
CMake 026:属性体系精讲、四大作用域全解 & 实战代码落地
c++·cmake
nujnewnehc12 小时前
不会 py, 用 ai 写了个游戏辅助的感受
人工智能·游戏
众少成多积小致巨1 天前
JNI (Java Native Interface) 技术手册中文参考指南
android·java·c++
jump_jump1 天前
为了重玩金庸群侠传,我研究了一下 Ruffle 怎么复活 Flash
游戏·rust·github
zzzzzz3102 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode2 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
Aloys_Code3 天前
逆向一个被遗忘的DVD游戏格式:从DES加密到Rust模拟器
游戏·模拟器·retroarch·复古游戏·native32·sunplus·赤刃·钢铁风暴
金銀銅鐵3 天前
用 Python 实现 Take-Away 游戏
python·游戏
金銀銅鐵4 天前
用 Pygame 实现 15 puzzle
python·数学·游戏