{"id":17338872,"url":"https://github.com/billyb2/bootleg_networking","last_synced_at":"2025-07-18T00:07:50.915Z","repository":{"id":45063205,"uuid":"439451955","full_name":"billyb2/bootleg_networking","owner":"billyb2","description":"A cross platform (wasm included) networking library!","archived":false,"fork":false,"pushed_at":"2022-05-10T17:36:44.000Z","size":48,"stargazers_count":58,"open_issues_count":2,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-14T04:32:32.214Z","etag":null,"topics":["bevy","gamdev","game-development","network-programming","networking","wasm"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/billyb2.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-17T20:26:56.000Z","updated_at":"2025-04-06T18:37:14.000Z","dependencies_parsed_at":"2022-08-12T11:40:56.555Z","dependency_job_id":null,"html_url":"https://github.com/billyb2/bootleg_networking","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/billyb2/bootleg_networking","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billyb2%2Fbootleg_networking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billyb2%2Fbootleg_networking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billyb2%2Fbootleg_networking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billyb2%2Fbootleg_networking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/billyb2","download_url":"https://codeload.github.com/billyb2/bootleg_networking/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/billyb2%2Fbootleg_networking/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265683355,"owners_count":23810835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bevy","gamdev","game-development","network-programming","networking","wasm"],"created_at":"2024-10-15T15:40:00.261Z","updated_at":"2025-07-18T00:07:50.888Z","avatar_url":"https://github.com/billyb2.png","language":"Rust","readme":"# bootleg_networking\nA cross platform (wasm included) networking library!\n\nA networking plugin for the Bevy game engine that wraps around bevy_networking_turbulence and a custom TCP/UDP network server in order to make writing cross-platform multiplayer games fun and easy!\n\n## Getting started\nCurrently, the library is not published on crates.io, due to a few forks of other popular libraries it currently uses. Because of this, in order to use the libary, you must specify it as a git dependency\n\n```toml\n[dependencies]\nbootleg_networking = { version = \"0.2\", git = \"https://github.com/billyb2/bootleg_networking\" }\n```\n\nIf you want to use this library with wasm, you should disable the native feature and enable the web feature\n\n```toml\n[dependencies]\nbootleg_networking = { version = \"0.2\", git = \"https://github.com/billyb2/bootleg_networking\", default-features = false, features = [\"web\"]}\n```\n\nI recommend pinning to a specific version, since library stability can change at any time.\n\nBelow is an example of how to use this library. It mainly shows how to setup a basic server, although a client is nearly identical\n\n```rust\nuse std::sync::Arc;\n\nuse bevy::prelude::*;\nuse bevy::tasks::IoTaskPool;\nuse bootleg_networking::*;\n\nconst MESSAGE_CHANNEL_ID: MessageChannelID = MessageChannelID::new(0);\nconst MESSAGE_SETTINGS: MessageChannelSettings = MessageChannelSettings {\n    channel: MESSAGE_CHANNEL_ID.id,\n    channel_mode: MessageChannelMode::Unreliable {\n\t\tsettings: turbulence::unreliable_channel::Settings {\n\t\t\tbandwidth: 4096,\n\t\t\tburst_bandwidth: 1024,\n\t\t},\n\t\tmax_message_len: 256,\t\n\t},\n    message_buffer_size: 256,\n    packet_buffer_size: 256,\n};\n\nfn main() {\n    let mut app = App::new();\n    app\n    .add_plugins(MinimalPlugins)\n    .add_plugin(NetworkingPlugin)\n    .add_startup_system(setup)\n    .add_system(send)\n    .add_system(receive);\n\n    //Uncomment the line below!\n    //app.run();\n}\n\nfn setup(mut commands: Commands, tokio_rt: Res\u003cRuntime\u003e, task_pool: Res\u003cIoTaskPool\u003e) {\n    // First we need to actually initiate the NetworkReource. In this case, it's a server\n    // We could use the new_client function if wanted a client\n    let mut net = NetworkResource::new_server(tokio_rt.clone(), task_pool.0.clone());\n\n    // Next, we need tell the server to setup listening\n    // The equivalent function for clients is connect\n    // Listen on ports 9000 for TCP and 9001 for UDP, and 9003\n    // The first address is the one that the connect() function needs to use, and the other two are for WebRTC\n    // Finally, the last argument is the maximum size of each packet. That argument is only necessary for native builds\n    let listen_config = ListenConfig {\n        tcp_addr: \"127.0.0.1:9000\",\n        udp_addr: \"127.0.0.1:9001\",\n        naia_addr: \"127.0.0.1:9003\",\n        webrtc_listen_addr: \"127.0.0.1:9004\",\n        public_webrtc_listen_addr: \"127.0.0.1:9004\",\n    };\n\n    net.listen(listen_config, Some(2048));\n    // If we were calling net.connect, the first argument we would either have 9000 or 9003 as the port, depending on whether we were a native client or a web client\n    // The second argument is only necessary on native builds, and it's asking for the UDP server SocketAddr\n    /* let connect_config = ConnectConfig {\n     *      addr: \"127.0.0.1:9000\",\n     *      udp_addr: Some(\"127.0.0.1:9001\"),\n     * };\n     *\n     * net.connect(connect_config, Some(2048));\n    */\n\n    // We need to register for the native tcp/udp server and for naia seperately\n    // Native registration\n    net.register_message_channel_native(MESSAGE_SETTINGS, \u0026MESSAGE_CHANNEL_ID).unwrap();\n    // Naia registration\n    net.set_channels_builder(|builder: \u0026mut ConnectionChannelsBuilder| {\n        builder\n            .register::\u003cString\u003e(MESSAGE_SETTINGS)\n            .unwrap();\n    });\n\n    // Finally, insert the network resource so it can be used by other systems\n    commands.insert_resource(net);\n\n}\n\n// The following two functions are equivalent for both clients and servers, provided you've set up the NetworkResource properly\n\nfn send(mut net: ResMut\u003cNetworkResource\u003e) {\n    let message = String::from(\"Hello world\");\n    net.broadcast_message(\u0026message, \u0026MESSAGE_CHANNEL_ID).unwrap();\n\n}\n\nfn receive(mut net: ResMut\u003cNetworkResource\u003e) {\n    let messages = net.view_messages::\u003cString\u003e(\u0026MESSAGE_CHANNEL_ID).unwrap();\n\n    for (_handle, message) in messages.iter() {\n        println!(\"{}\", message);\n\n    }\n\n}\n```\n## Warning about sending messages larger than 1095 bytes\n@totalkrill noticed that when attempting to send a message larger than 1095 bytes, the message wouldn't go through. This is due to a limitation in WebRTC that doesn't allow messages larger than 1200 bytes (which 1095 bytes + any overhead in the WebRTC protocol and anything Naia adds would definetly do). The NetworkResource will return an error upon trying to send a message above that size when sending it through Naia, though there isn't an issue on the TCP/UDP front. Just be warned though, that if you're trying to have cross platform compatibility, messages should be under that size.\n\n\n## If the crate isn't published on crates.io, how do I view the documentation?\nSimply run `cargo doc` in the terminal. If you want to view the documentation for the web version of this crate, then run `cargo doc --no-default-features --features web`\n\n## Why make this crate\nWhile working with the wonderful bevy_networking_turbulence library, I realized that I wasn't able to create network clients on anything other than wasm. While it is doable using the fantastic new WebRTC-rs library (and I [even attempted it](https://github.com/naia-rs/naia-socket/pull/46), it still currently isn't possible. After a lot of effort, I eventually gave up, and decided instead to write this library. While initially, it was just for internal use in a project I'm workin on, I realized that it would have a lot of potential as a public library.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillyb2%2Fbootleg_networking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbillyb2%2Fbootleg_networking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbillyb2%2Fbootleg_networking/lists"}