推荐一个基于协程的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++处理文件上传的
相关推荐
超级架构师5 分钟前
让 COBOL 长出 AI 大脑:原生 Agent 核心框架 praxo-core 深度剖析
c语言·开发语言·c++·人工智能·python·架构·ai编程
红红谈说7 分钟前
定时发布关机就停,本地定时任务的补跑策略怎么设计?
运维·服务器·定时任务·本地调度·补跑策略·幂等互斥·执行记录
·present·9 分钟前
CSAPP(lecture 10)
c语言·c++
YLCHUP14 分钟前
【模拟&STL】题解:AT_abc203_e [ABC203E] White Pawn_基础算法_数据结构_STL模板库_AtcoderABC_C++算法竞赛
数据结构·c++·算法·leetcode·动态规划·哈希算法·近邻算法
2401_8685347828 分钟前
论纯IPv6(IPv6-Only)演进与地址规划设计与实施
服务器·网络
xiaolang_8616_wjl29 分钟前
c++游戏_宝可梦大世界(源代码)
开发语言·c++·游戏
爱和冰阔落35 分钟前
【Linux网络】UDP 服务器怎么写?从 socket、bind 到 recvfrom/sendto,手写完整回显服务器
linux·运维·服务器·网络
知已难寻44 分钟前
00 · OpenStack 总纲——从云计算到 OpenStack 全景
运维·服务器·云原生·云计算·负载均衡·openstack·perl
小白的码BUG之路44 分钟前
K8S -- 集群搭建环境基础
java·服务器·kubernetes
余额瞒着我当琳1 小时前
C++异常,异常的概念,异常抛出与捕获,RAII 和智能指针的设计思路,C++标准库一些指针的使用
java·开发语言·c++·算法