| Crates.io | aerox |
| lib.rs | aerox |
| version | 0.1.1 |
| created_at | 2025-12-28 13:13:46.683103+00 |
| updated_at | 2025-12-28 13:13:46.683103+00 |
| description | AeroX - 高性能游戏服务器后端框架 |
| homepage | |
| repository | https://github.com/cherish-ltt/AeroX |
| max_upload_size | |
| id | 2008808 |
| size | 241,197 |
AeroX 是一个基于 Rust 开发的专注于游戏服务器后端和实时消息转发场景的高性能框架。它采用 Reactor 模式实现高并发连接处理,整合 Bevy ECS 架构,提供模块化、可扩展的解决方案。
Application Layer ┌─────────┐ ┌─────────┐ ┌─────────┐
│ PluginA │ │ PluginB │ │ PluginC │
└─────────┘ └─────────┘ └─────────┘
Framework Core ┌─────────┐ ┌─────────┐ ┌─────────┐
│ Router │ │ ECS │ │ Config │
└─────────┘ └─────────┘ └─────────┘
Network Layer ┌─────────┐ ┌─────────┐ ┌─────────┐
│ TCP │ │ KCP │ │ QUIC │
└─────────┘ └─────────┘ └─────────┘
将以下内容添加到 Cargo.toml:
[dependencies]
aerox = "0.1"
AeroX 支持按需编译,您可以选择只启用需要的功能:
# 默认:包含服务器和客户端功能
aerox = "0.1"
# 仅服务器
aerox = { version = "0.1", default-features = false, features = ["server"] }
# 仅客户端
aerox = { version = "0.1", default-features = false, features = ["client"] }
展示如何使用 AeroX 构建完整的 ECS 游戏服务器:
# 终端 1 - 启动服务器
cargo run --example ecs_basics -- server
# 终端 2 - 启动客户端
cargo run --example ecs_basics -- client
# 终端 3 - 启动另一个客户端(多玩家测试)
cargo run --example ecs_basics -- client
功能特性:
展示自定义中间件和路由系统:
# 终端 1 - 启动服务器
cargo run --example router_middleware -- server
# 终端 2 - 启动客户端(测试认证、限流等)
cargo run --example router_middleware -- client
功能特性:
展示多玩家游戏服务器的完整实现:
# 终端 1 - 启动服务器
cargo run --example complete_game_server -- server
# 终端 2,3,4... - 启动多个客户端
cargo run --example complete_game_server -- client
功能特性:
运行性能基准测试:
cargo run --example benchmark
详见 BENCHMARK.md
重要说明:
start.rs 是实验性示例,使用了未完成的高级 API,请勿在生产环境使用use aerox::Server;
#[tokio::main]
async fn main() -> aerox::Result<()> {
Server::bind("127.0.0.1:8080")
.route(1001, |ctx| async move {
println!("收到消息: {:?}", ctx.data());
Ok(())
})
.run()
.await
}
use aerox::Client;
#[tokio::main]
async fn main() -> aerox::Result<()> {
let mut client = Client::connect("127.0.0.1:8080").await?;
// 注册消息处理器
client.on_message(1001, |id, msg: MyMessage| async move {
println!("收到: {:?}", msg);
Ok(())
}).await?;
// 发送消息
client.send(1001, &my_message).await?;
Ok(())
}
| Crate | 描述 |
|---|---|
aerox_core |
核心运行时和插件系统 |
aerox_network |
网络层抽象和协议实现 |
aerox_protobuf |
Protobuf 编解码支持 |
aerox_ecs |
Bevy ECS 整合层 |
aerox_router |
路由和中间件系统 |
aerox_plugins |
内置插件 |
aerox_config |
配置管理 |
aerox_client |
客户端库 |
当前版本: v0.1.1
完成度: 100% (核心功能全部完成)
# 运行所有测试
cargo test
# 运行示例
cargo run --example ecs_basics -- server
cargo run --example ecs_basics -- client
# 性能测试
cargo run --example benchmark
测试覆盖: 129 tests,所有通过 ✅
欢迎贡献!
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)本项目采用 MIT 许可证 - 详见 LICENSE 文件