Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A library for easily creating WebRTC data channel connections in Rust

License

Notifications You must be signed in to change notification settings

somenever/cyberdeck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

60 Commits

Repository files navigation

docs.rs docs

Cyberdeck

A library for easily creating WebRTC data channel connections in Rust.

cargo add cyberdeck
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.

cargo run --example signaling_server

Art

Cyberpunk crab

License

This project is licensed under either of

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.

About

A library for easily creating WebRTC data channel connections in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%

AltStyle によって変換されたページ (->オリジナル) /