From 156e26da1c5dbf05615f081c3b8784f1dd7ea419 Mon Sep 17 00:00:00 2001 From: aggyomfg Date: Thu, 29 Feb 2024 12:03:15 +0400 Subject: [PATCH] upgrade to bevy 0.13 --- .gitignore | 1 - .vscode/settings.json | 3 +++ Cargo.toml | 4 ++-- README.md | 8 +++++++- src/client.rs | 10 +++++----- src/server.rs | 6 +++--- 6 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.gitignore b/.gitignore index 0dc9e19..ee8c51d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ /target /Cargo.lock /.idea -/.vscode /.cargo/config /.cargo/config.toml /*.iml diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5ba99a9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "rust-analyzer.cargo.features": ["serializer_bincode", "protocol_tcp", "protocol_udp", "client", "server"] +} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 58c18fc..a346a7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_slinet" -version = "0.8.0" +version = "0.9.0" authors = ["Sliman4 <4sliman4@gmail.com>"] edition = "2021" license = "Apache-2.0 OR MIT" @@ -22,7 +22,7 @@ features = [ ] [dependencies] -bevy = { version = "0.12.*", default-features = false } +bevy = { version = "0.13", default-features = false } serde = "1" byteorder = "1" bincode = { version = "1", optional = true } diff --git a/README.md b/README.md index e1b5b25..64c7868 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # bevy_slinet + A simple networking plugin for bevy. [![docs.rs](https://img.shields.io/docsrs/bevy_slinet)](https://docs.rs/bevy_slinet) @@ -6,6 +7,7 @@ A simple networking plugin for bevy. [![Crates.io](https://img.shields.io/crates/l/bevy_slinet)](https://github.com/Sliman4/bevy_slinet/tree/main/LICENSE) ## Features + - You can choose TCP or UDP protocol. Adding your own protocols is as easy as implementing a few traits. - Multiple clients/servers with different configs (specifies a protocol, packet types, serializer, etc.) - De/serialization. You choose a serialization format, packet type (you probably want it to be `enum`), and receive events with deserialized packets. @@ -13,6 +15,7 @@ A simple networking plugin for bevy. > Note: Everything in bevy_slinet is feature-gated. Make sure to enable features you need (`client`, `server`, `protocol_tcp`, `protocol_udp`, `serializer_bincode`). ## Client example + ```rust use bevy::prelude::*; use serde::{Deserialize, Serialize}; @@ -132,9 +135,11 @@ fn packet_receive_system(mut events: EventReader>) { Note: you should implement keep-alive and disconnection systems yourself, or look at [lobby_and_battle_servers example](examples/lobby_and_battle_servers.rs) ## More examples + [Here](https://github.com/Sliman4/bevy_slinet/tree/main/examples). ### Compatibility table + | Plugin Version | Bevy Version | |----------------|--------------| | `0.1` | `0.6` | @@ -145,4 +150,5 @@ Note: you should implement keep-alive and disconnection systems yourself, or loo | `0.6` | `0.10.1` | | `0.7` | `0.11` | | `0.8` | `0.12` | -| `main` | `0.12` | +| `0.9` | `0.13` | +| `main` | `0.13` | diff --git a/src/client.rs b/src/client.rs index ae33ccc..67c3e79 100644 --- a/src/client.rs +++ b/src/client.rs @@ -346,7 +346,7 @@ fn packet_receive_system( mut event_writer: EventWriter>, ) { while let Ok((connection, packet)) = packets.0.try_recv() { - event_writer.send(PacketReceiveEvent { connection, packet }) + let _id = event_writer.send(PacketReceiveEvent { connection, packet }); } } @@ -359,10 +359,10 @@ fn connection_establish_system( while let Ok((address, connection)) = new_connections.0.try_recv() { commands.insert_resource(connection.clone()); connections.push(connection.clone()); - event_writer.send(ConnectionEstablishEvent { + let _id = event_writer.send(ConnectionEstablishEvent { address, connection, - }) + }); } } @@ -378,11 +378,11 @@ fn connection_remove_system( if let Some(connection) = connections.last() { commands.insert_resource(connection.clone()); } - event_writer.send(DisconnectionEvent { + let _id = event_writer.send(DisconnectionEvent { error, address, _marker: PhantomData, - }) + }); } } diff --git a/src/server.rs b/src/server.rs index 283f01d..ee3a92c 100644 --- a/src/server.rs +++ b/src/server.rs @@ -318,10 +318,10 @@ fn accept_new_connections( mut event_writer: EventWriter>, ) { while let Ok((address, connection)) = receiver.0.try_recv() { - event_writer.send(NewConnectionEvent { + let _id = event_writer.send(NewConnectionEvent { connection, address, - }) + }); } } @@ -330,7 +330,7 @@ fn accept_new_packets( mut event_writer: EventWriter>, ) { while let Ok((connection, packet)) = receiver.0.try_recv() { - event_writer.send(PacketReceiveEvent { connection, packet }) + let _id = event_writer.send(PacketReceiveEvent { connection, packet }); } }