@@ -2,21 +2,13 @@ extern crate hbb_common;
22
33#[ cfg( feature = "webrtc" ) ]
44use hbb_common:: webrtc:: WebRTCStream ;
5- #[ cfg( not( feature = "webrtc" ) ) ]
6- mod webrtc_dummy;
7- #[ cfg( not( feature = "webrtc" ) ) ]
8- use crate :: webrtc_dummy:: WebRTCStream ;
95
106use std:: io:: Write ;
11-
127use anyhow:: Result ;
138use bytes:: Bytes ;
149use clap:: { Arg , Command } ;
1510use tokio:: time:: Duration ;
1611
17- #[ cfg( feature = "webrtc" ) ]
18- use webrtc:: peer_connection:: math_rand_alpha;
19-
2012#[ cfg( not( feature = "webrtc" ) ) ]
2113#[ tokio:: main]
2214async fn main ( ) -> Result < ( ) > {
@@ -121,6 +113,7 @@ async fn main() -> Result<()> {
121113}
122114
123115// read_loop shows how to read from the datachannel directly
116+ #[ cfg( feature = "webrtc" ) ]
124117async fn read_loop ( mut stream : WebRTCStream ) -> Result < ( ) > {
125118 loop {
126119 let Some ( res) = stream. next ( ) . await else {
@@ -140,6 +133,7 @@ async fn read_loop(mut stream: WebRTCStream) -> Result<()> {
140133}
141134
142135// write_loop shows how to write to the webrtc stream directly
136+ #[ cfg( feature = "webrtc" ) ]
143137async fn write_loop ( mut stream : WebRTCStream ) -> Result < ( ) > {
144138 let mut result = Result :: < ( ) > :: Ok ( ( ) ) ;
145139 while result. is_ok ( ) {
@@ -148,7 +142,7 @@ async fn write_loop(mut stream: WebRTCStream) -> Result<()> {
148142
149143 tokio:: select! {
150144 _ = timeout. as_mut( ) =>{
151- let message = math_rand_alpha( 15 ) ;
145+ let message = webrtc :: peer_connection :: math_rand_alpha( 15 ) ;
152146 result = stream. send_bytes( Bytes :: from( message. clone( ) ) ) . await ;
153147 println!( "Sent '{message}' {}" , result. is_ok( ) ) ;
154148 }
0 commit comments