Skip to content

Conversation

@stuqdog
Copy link
Contributor

@stuqdog stuqdog commented Jul 12, 2022

Allows for acceptance of already created data channels. Duplicates logic already existing in pion at https://github.com/pion/webrtc/blob/master/sctptransport.go#L162.

Note that this is a sibling(niece?) pr of webrtc-rs/data#14; it relies on that pr and won't compile until that pr is merged.

let mut existing_data_channels = Vec::new();
for dc in dcs.iter() {
if let Some(dc) = dc.data_channel.lock().await.clone() {
let dc2 = dc.as_ref().clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the second clone? if it's an already cloned object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good question! The clone() should be to_owned() instead.

async fn accept_data_channels(param: AcceptDataChannelParams) {
let dcs = param.data_channels.lock().await;
let mut existing_data_channels = Vec::new();
for dc in dcs.iter() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also one idea I just had is to modify DataChannel::accept to accept a reference to a list of existing data channels. That way we won't need to clone all of them, just the one with matching identifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 will make a PR to update there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

melekes added a commit to melekes/webrtc that referenced this pull request Jul 20, 2022
Allows for acceptance of already created data channels. Duplicates logic
already existing in pion at
https://github.com/pion/webrtc/blob/master/sctptransport.go#L162.

Refs webrtc-rs/data#14
Replaces webrtc-rs#219

Co-authored-by: stuqdog <ethanrodkin@protonmail.com>
@melekes melekes closed this Jul 20, 2022
melekes added a commit that referenced this pull request Jul 21, 2022
* update call to DataChannel::accept as per data pr #14

Allows for acceptance of already created data channels. Duplicates logic
already existing in pion at
https://github.com/pion/webrtc/blob/master/sctptransport.go#L162.

Refs webrtc-rs/data#14
Replaces #219

Co-authored-by: stuqdog <ethanrodkin@protonmail.com>

* bump data and sctp crates versions

Co-authored-by: stuqdog <ethanrodkin@protonmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants