Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/richardanaya/cyberdeck
A library for easily creating WebRTC data channel connections in Rust
https://github.com/richardanaya/cyberdeck
rust webrtc
Last synced: about 2 months ago
JSON representation
A library for easily creating WebRTC data channel connections in Rust
- Host: GitHub
- URL: https://github.com/richardanaya/cyberdeck
- Owner: richardanaya
- License: apache-2.0
- Created: 2021-10-15T02:30:29.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T18:49:59.000Z (almost 2 years ago)
- Last Synced: 2024-11-16T14:19:10.531Z (3 months ago)
- Topics: rust, webrtc
- Language: Rust
- Homepage:
- Size: 67.4 KB
- Stars: 41
- Watchers: 3
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Cyberdeck
A library for easily creating WebRTC data channel connections in Rust.```toml
cargo add cyberdeck
``````rust
let mut peer = Peer::new(|peer_id, e| async move {
match e {
PeerEvent::DataChannelMessage(c, m) => {
println!(
"{}::Recieved a message from channel {}!",
peer_id,
c.label()
);
let msg_str = String::from_utf8(m.data.to_vec()).unwrap();
println!(
"{}::Message from DataChannel '{}': {}",
peer_id,
c.label(),
msg_str
);
}
PeerEvent::DataChannelStateChange(c) => {
if c.ready_state() == RTCDataChannelState::Open {
println!("{}::DataChannel '{}'", peer_id, c.label());
c.send_text("Connected to client!".to_string())
.await
.unwrap();
} else if c.ready_state() == RTCDataChannelState::Closed {
println!("{}::DataChannel '{}'", peer_id, c.label());
}
}
PeerEvent::PeerConnectionStateChange(s) => {
println!("{}::Peer connection state: {} ", peer_id, s)
}
}
})
.await?;
let answer = peer.receive_offer(&offer).await?;
```# Signaling server
WebRTC works in it's most basic form by having the client and server exchange strings that represent their networking information. A signaling server is just some API that you exchange that information through. You can see a simple signaling server implemented with a single POST http handler here in this example [here](https://github.com/richardanaya/cyberdeck/blob/master/examples/signaling_server.rs).
```bash
cargo run --example signaling_server
```# Art
![Cyberpunk crab](https://user-images.githubusercontent.com/294042/222991163-9ef095eb-98da-419f-8f06-b1ea1d51f34d.png)
# 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.
### Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in `cyberdeck` by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.