| Crates.io | sustenet-cluster |
| lib.rs | sustenet-cluster |
| version | 0.1.4 |
| created_at | 2025-04-20 01:59:43.536957+00 |
| updated_at | 2025-04-26 03:13:46.109111+00 |
| description | Sustenet's cluster module that connects to the master server and accepts client connections after being registered. |
| homepage | https://github.com/Quaint-Studios/Sustenet |
| repository | |
| max_upload_size | |
| id | 1641292 |
| size | 74,080 |
sustenet-cluster is the cluster server crate for Sustenet's networking solution. It connects to the master server, manages game clients, and handles distributed game logic as part of a scalable cluster architecture. Each cluster server communicates with the master and other clusters to provide seamless multiplayer experiences.
Sustenet is a networking solution for game engines. It's made to primarily be used for MMO or large-scale multiplayer games in Godot Engine but can also be used in Unity and Unreal Engine. Support for other engines will continue to grow over time.
sustenet-shared crate.main.rs: Entry point for the cluster server, handles startup and main event loop.lib.rs: Core logic for cluster operation, including master connection, client handling, and plugin integration.use sustenet::cluster::{ cleanup, error, start };
use sustenet::shared::ServerPlugin;
use tokio::sync::mpsc::Sender;
struct Reia;
impl ServerPlugin for Reia {
fn receive(
&self,
tx: Sender<Box<[u8]>>,
command: u8
) -> std::pin::Pin<Box<dyn std::future::Future<Output = ()> + Send>> {
Box::pin(async move {
// You can modify this with a `match` statement to be more
// organized.
// Sends data whenever a custom command comes in.
// The code "20" has no significance. But the max possible code
// is 255. If for some reason you needed more, you can always
// mix two u8s together (i.e. [20, 1]).
if let Err(e) = tx.send(Box::new([20])).await {
error(format!("Failed to send message. {e}").as_str());
}
})
}
fn info(&self, message: &str) {
println!("{message}");
}
}
#[tokio::main]
async fn main() {
start(Reia {}).await;
cleanup().await;
}
The configuration file is Config.toml. Below is an example configuration:
[all]
server_name = "Default Cluster Server"
max_connections = 0
port = 0
[cluster]
key_name = "cluster_key"
master_ip = "127.0.0.1"
master_port = 0
domain_pub_key = "https://www.playreia.com/game/pubkey.pub" # Remove this if you want to use the server's bandwidth to send a key to a user directly. | This isn't implemented yet but will be in the future.
This project is licensed under the MIT license.