Skip to content

Commit

Permalink
get rid of negotiated arg
Browse files Browse the repository at this point in the history
turns out we can pass negotiated: true and id=1 on both ends.
  • Loading branch information
melekes committed Aug 29, 2022
1 parent 59e0ded commit a2c74c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 2 additions & 3 deletions transports/webrtc/src/transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl Transport for WebRTCTransport {
.await?;

// Open a data channel to do Noise on top and verify the remote.
let data_channel = conn.create_initial_upgrade_data_channel(false).await?;
let data_channel = conn.create_initial_upgrade_data_channel().await?;

trace!("noise handshake with addr={}", remote);
let peer_id = perform_noise_handshake_outbound(
Expand Down Expand Up @@ -577,8 +577,7 @@ async fn upgrade(
.await?;

// Open a data channel to do Noise on top and verify the remote.
// NOTE: channel is already negotiated by the client
let data_channel = conn.create_initial_upgrade_data_channel(true).await?;
let data_channel = conn.create_initial_upgrade_data_channel().await?;

trace!(
"noise handshake with addr={} (ufrag={})",
Expand Down
7 changes: 2 additions & 5 deletions transports/webrtc/src/webrtc_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,15 @@ impl WebRTCConnection {
return Ok(Self { peer_connection });
}

pub async fn create_initial_upgrade_data_channel(
&self,
negotiated: bool,
) -> Result<Arc<DataChannel>, Error> {
pub async fn create_initial_upgrade_data_channel(&self) -> Result<Arc<DataChannel>, Error> {
// Open a data channel to do Noise on top and verify the remote.
let data_channel = self
.peer_connection
.create_data_channel(
"data",
Some(RTCDataChannelInit {
id: Some(1),
negotiated: if negotiated { Some(negotiated) } else { None },
negotiated: Some(true),
..RTCDataChannelInit::default()
}),
)
Expand Down

0 comments on commit a2c74c6

Please sign in to comment.