Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cympletech/tdn-bevy
TDN plugin for Bevy game engine.
https://github.com/cympletech/tdn-bevy
bevy-plugin p2p websocket
Last synced: 8 days ago
JSON representation
TDN plugin for Bevy game engine.
- Host: GitHub
- URL: https://github.com/cympletech/tdn-bevy
- Owner: CympleTech
- License: apache-2.0
- Created: 2024-02-04T03:35:29.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-28T04:04:08.000Z (10 months ago)
- Last Synced: 2024-11-16T18:31:06.666Z (about 1 month ago)
- Topics: bevy-plugin, p2p, websocket
- Language: Rust
- Homepage:
- Size: 18.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# tdn-bevy
TDN plugin for Bevy game engine.## Feature
- Support websocket client
- Support websocket in browser (wasm)
- Support http client in browser (wasm)
- Support P2P network
- Latest Bevy (0.13+)## Usage
```tdn-bevy = "0.1.2"```### Websocket client
```rust
use tdn_bevy::{RecvError, ws::{WsClient, WsClientPlugin, WsConnection}};fn main() {
App::new()
.add_plugins(WsClientPlugin)
.add_systems(Startup, connect_ws)
.add_systems(Update, receive_message)
.run();
}fn connect_ws(mut commands: Commands, ws_client: Res) {
ws_client.connect(&mut commands, "127.0.0.1:8000", None);
}fn receive_message(mut commands: Commands, connections: Query<(Entity, &WsConnection)>) {
for (entity, conn) in connections.iter() {
loop {
match conn.recv() {
Ok(message) => {
println!("message: {}", message);
conn.send(message);
}
Err(RecvError::Empty) => break,
Err(RecvError::Closed) => {
commands.entity(entity).despawn();
break;
}
}
}
}
}```
### P2P network
DOING## License
This project is licensed under either of
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
http://opensource.org/licenses/MIT)at your option.