All Projects → ncallaway → bevy_prototype_networking_laminar

ncallaway / bevy_prototype_networking_laminar

Licence: MIT license
This is a prototype of a networking crate for bevy. This create provides a low-level networking plugin built on top of laminar

Programming Languages

rust
11053 projects
shell
77523 projects

Projects that are alternatives of or similar to bevy prototype networking laminar

bevy retrograde
Plugin pack for making 2D games with Bevy
Stars: ✭ 212 (+606.67%)
Mutual labels:  bevy
taileater
A puzzle game where you eat your own tail to win!
Stars: ✭ 19 (-36.67%)
Mutual labels:  bevy
dango-tribute
👀
Stars: ✭ 20 (-33.33%)
Mutual labels:  bevy
bevy 4x camera
A 4X style camera for bevy.
Stars: ✭ 26 (-13.33%)
Mutual labels:  bevy
space
A SCI-FI community game server simulating space(ships). Built from the ground up to support moddable online action multiplayer and roleplay!
Stars: ✭ 25 (-16.67%)
Mutual labels:  bevy
kurinji
Kurinji Input Map aims to decouple game play code from device specific input api. This is achieved by providing apis that allows you to map game actions to device input events instead of directly handling device inputs.
Stars: ✭ 47 (+56.67%)
Mutual labels:  bevy
bevy template
Compile-time optimized Bevy project template
Stars: ✭ 27 (-10%)
Mutual labels:  bevy
bevy mod bounding
Unofficial plugin for generating bounding boxes in Bevy
Stars: ✭ 21 (-30%)
Mutual labels:  bevy
bevy kira audio
A Bevy plugin to use Kira for game audio
Stars: ✭ 99 (+230%)
Mutual labels:  bevy
bevy tilemap
Tilemap with chunks for the Bevy game engine.
Stars: ✭ 169 (+463.33%)
Mutual labels:  bevy
bevy
A refreshingly simple data-driven game engine built in Rust
Stars: ✭ 15,920 (+52966.67%)
Mutual labels:  bevy
bevy lint
A Linter for bevy code
Stars: ✭ 21 (-30%)
Mutual labels:  bevy
frontroute
front-end router library for single-page applications built with Scala.js, with an API inspired by Akka HTTP
Stars: ✭ 22 (-26.67%)
Mutual labels:  laminar
bevy-robbo
Port of mrk-its/rust-robbo to bevy
Stars: ✭ 33 (+10%)
Mutual labels:  bevy
bevy chess
Chess demo in Bevy
Stars: ✭ 59 (+96.67%)
Mutual labels:  bevy
rgis
Performant, cross-platform (web, desktop) GIS app written in Rust
Stars: ✭ 79 (+163.33%)
Mutual labels:  bevy
bevy transform gizmo
A 3d gizmo for transforming entities in Bevy.
Stars: ✭ 41 (+36.67%)
Mutual labels:  bevy
bevy config cam
A Swiss Army knife of a camera plugin that allows for easy setup and configuration of a wide variety of types of moveable cameras and player cameras for a scene.
Stars: ✭ 155 (+416.67%)
Mutual labels:  bevy
libracity
LibraCity - City planning on a needle! LibraCity is a puzzle game where you build a city at equilibrium on a needle. To succeed, take advantage of the various weights of the buildings, and place them all while ensuring the city remains stable.
Stars: ✭ 22 (-26.67%)
Mutual labels:  bevy
http4s-laminar-stack
A complete example of a fullstack (I actually don't know what this means) Scala application, using http4s on the backend and Laminar and Scala.js on the frontend
Stars: ✭ 43 (+43.33%)
Mutual labels:  laminar

Bevy Prototype Networking Laminar Plugin

Crates.io MIT License

Warning: This is a prototype and not ready for production use

This is a prototype of a networking crate for bevy. This create provides a low-level networking plugin built on top of laminar, which adds some simple reliability, ordering, and virtual connection options on top of a UDP socket.

Getting Started

  1. Add bevy_prototype_networking_laminar to Cargo.toml
[dependencies]
bevy = "0.1"
bevy_prototype_networking_laminar = "0.1"
  1. Add the NetworkPlugin to your bevy app setup
use bevy_prototype_networking_laminar::NetworkingPlugin;

...

app
  .add_default_plugins()
> .add_plugin(NetworkingPlugin)
  .add_system(...)
  1. Use the NetworkResource to bind to a socket and send/broadcast messages
fn startup_system(net: ResMut<NetworkResource>) {
  net.bind("127.0.0.1:12350").unwrap();
}

fn greeting_system(net: Res<NetworkResource>) {
  net.broadcast(b"How is everybody?", NetworkDelivery::ReliableSequenced(Some(1))).unwrap();
}
  1. Listen for NetworkEvents to receive incoming messages
#[derive(Default)]
struct NetworkListenerState {
    network_events: EventReader<NetworkEvent>,
}

App::build()
        .add_default_plugins()
        .add_plugin(NetworkingPlugin)
      > .init_resource::<NetworkListenerState>()
      > .add_system(print_network_events.system())
        .run();

fn print_network_events(
    mut state: ResMut<NetworkListenerState>,
    network_events: Res<Events<NetworkEvent>>,
) {
    for event in state.network_events.iter(&network_events) {
        println!("Received a NetworkEvent: {:?}", event);
    }
}

Examples

testbed

The testbed is a simple project that provides a more comprehensive example of using bevy_prototype_networking_laminar.

Testbed Screenshot

The testbed is also is intended to serve as a testbed for any other networking prototypes or attempts. All interaction with bevy_prototype_networking_laminar is contained to examples/testbed/net/prototype.rs. Using the testbed with a different networking plugin should be as simple as updating prototype.rs to interact with the other networking plugin. Contributions to the testbed to improve the code quality, or make the testbed more comprehensive by adding other prototypical network interactions are welcome.

  • cargo run --example testbed -- -s 127.0.0.1:12540 to start a server
  • cargo run --example testbed -- -c 127.0.0.1:12541 127.0.0.1:12540 foo to start a client named foo connecting to the server

Server

When on the server, you:

  • can control the position of the cube with WASD
  • can click the "send a note" button to add random note to the NOTES list

Client

When on the client, you:

  • cannot control the position of the cube
  • the cube's position should be syncrhonized with the server
  • you can click the "send a note" button to add a random note to the NOTES list
  • the NOTES list is syncrhonized with the server.

simple

The simple example shows a very bare bones bevy application that will send messages back and forth.

  • cargo run --example simple -- -s start a server
  • cargo run --example simple -- -c start a client
$ cargo run --example simple -- -s
---> "How are things over there?"
<--- "Good." from 127.0.0.1:12350
        Connected: 127.0.0.1:12350
---> "How are things over there?"
<--- "Good." from 127.0.0.1:12350
---> "How are things over there?"

multisocket

This shows the ability to bind to multiple sockets.

$ cargo run --example multisocket
[SERVER] ---> "How are things?"
         ---> [CLIENT] "How are things?"

[CLIENT] ---> "Good. Thanks!"
         ---> [SERVER] "Good. Thanks!"

[SERVER] ---> "How are things?"
         ---> [CLIENT] "How are things?"

Future Work

The current prototype implementation is extremely rough and early. The current work is mostly about exploring to discover a Network Plugin API that fits the bevy design. Listed here is the current low-hanging fruit for improving this prototype:

  • #3 Closing sockets: The prototype right now doesn't have the ability to manually close a socket. Sockets are closed when the application exists. Add the functionality to manually close a socket.
  • Improve testbed: The testbed has a number of areas that could be improved
    • Repository split: If other projects have interest in using the testbed, split it out into it's own create/repository.
    • #4 Code cleanup: net/prototype interface: The testbed has some rough areas in the split between the net/mod.rs and net/prototype.rs. Consider cleaning up this interface to make it cleaner to implement a plugin integration
    • #6 Code cleanup: Message sync: The messages are currently fully serialized whenever a message is changed. Clean this up to be a better representation of the desired sync model so that the server only sends the changes on a Reliable channel, and the Client can request the full list of messages when they connect, or need to reset their state.
    • Explore additional prototypical network interactions: The server sync'd cube example relies on there being a single cube. Consider introducing something that has multiple copies being sync'd to demonstrate sharing stable IDs across the network. Find other ways to expand the testbed to be more representative of the needs of real games.
  • Explore additional useful networking features: amethyst-network exposes a network simulation time, which helps synchornize time and track frame lag when sending network messages over the system. Explore this concept, and other common networking tasks that would be useful in a low-level networking plugin.
  • Explore shared transport API: Explore sharing a similar API surface with other Networking Plugins (or integrating other transports into this plugin), so that callers can easily switch between UDP, TCP, Laminar, WebRTC, Naia, etc.

ACKs

  • Thanks first of all to the amethyst team for laminar
  • Thanks again to the amethyst team for amethyst-network

License

Licesened under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].