A simple networking plugin for bevy.
enum
), and receive events with deserialized packets.Note: Everything in bevy_slinet is feature-gated. Make sure to enable features you need (
client
,server
,protocol_tcp
,protocol_udp
,serializer_bincode
).
```rust use bevy::prelude::*; use serde::{Deserialize, Serialize};
use bevyslinet::client::{ClientPlugin, ConnectionEstablishEvent, PacketReceiveEvent}; use bevyslinet::packetlengthserializer::LittleEndian; use bevyslinet::protocols::tcp::TcpProtocol; use bevyslinet::serializers::bincode::{BincodeSerializer, DefaultOptions}; use bevy_slinet::ClientConfig;
struct Config;
impl ClientConfig for Config {
type ClientPacket = ClientPacket;
type ServerPacket = ServerPacket;
type Protocol = TcpProtocol;
type Serializer = BincodeSerializer
enum ClientPacket { String(String), }
enum ServerPacket { String(String), }
fn main() {
App::new()
.addplugins(MinimalPlugins)
.addplugin(ClientPlugin::
fn connectionestablishsystem(mut events: EventReader
fn packetreceivesystem(mut events: EventReader
```rust use bevy::prelude::*; use serde::{Deserialize, Serialize};
use bevyslinet::packetlengthserializer::LittleEndian; use bevyslinet::protocols::tcp::TcpProtocol; use bevyslinet::serializers::bincode::{BincodeSerializer, DefaultOptions}; use bevyslinet::server::{NewConnectionEvent, ServerPlugin, PacketReceiveEvent}; use bevy_slinet::ServerConfig;
struct Config;
impl ServerConfig for Config {
type ClientPacket = ClientPacket;
type ServerPacket = ServerPacket;
type Protocol = TcpProtocol;
type Serializer = BincodeSerializer
enum ClientPacket { String(String), }
enum ServerPacket { String(String), }
fn main() {
App::new()
.addplugins(MinimalPlugins)
.addplugin(ServerPlugin::
fn newconnectionsystem(mut events: EventReader
fn packetreceivesystem(mut events: EventReader
Note: you should implement keep-alive and disconnection systems yourself, or look at lobbyandbattle_servers example
Here.
| Plugin Version | Bevy Version |
|----------------|--------------|
| 0.1
| 0.6
|
| 0.2
| 0.6
|
| 0.3
| 0.7
|
| 0.4
| 0.8
|
| 0.5
| 0.9
|
| main
| 0.9
|