Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/data_channel/data_channel_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async fn pr_ordered_unordered_test(channel_type: ChannelType, is_ordered: bool)
let dc0 = DataChannel::dial(&a0, 100, cfg.clone()).await?;
bridge_process_at_least_one(&br).await;

let dc1 = DataChannel::accept(&a1, Config::default()).await?;
let dc1 = DataChannel::accept(&a1, Config::default(), Vec::new()).await?;
bridge_process_at_least_one(&br).await;

assert_eq!(dc0.config, cfg, "local config should match");
Expand Down Expand Up @@ -274,7 +274,7 @@ async fn test_data_channel_channel_type_reliable_ordered() -> Result<()> {
let dc0 = DataChannel::dial(&a0, 100, cfg.clone()).await?;
bridge_process_at_least_one(&br).await;

let dc1 = DataChannel::accept(&a1, Config::default()).await?;
let dc1 = DataChannel::accept(&a1, Config::default(), Vec::new()).await?;
bridge_process_at_least_one(&br).await;

assert_eq!(dc0.config, cfg, "local config should match");
Expand Down Expand Up @@ -336,7 +336,7 @@ async fn test_data_channel_channel_type_reliable_unordered() -> Result<()> {
let dc0 = DataChannel::dial(&a0, 100, cfg.clone()).await?;
bridge_process_at_least_one(&br).await;

let dc1 = DataChannel::accept(&a1, Config::default()).await?;
let dc1 = DataChannel::accept(&a1, Config::default(), Vec::new()).await?;
bridge_process_at_least_one(&br).await;

assert_eq!(dc0.config, cfg, "local config should match");
Expand Down Expand Up @@ -434,7 +434,7 @@ async fn test_data_channel_buffered_amount() -> Result<()> {
);
bridge_process_at_least_one(&br).await;

let dc1 = Arc::new(DataChannel::accept(&a1, Config::default()).await?);
let dc1 = Arc::new(DataChannel::accept(&a1, Config::default(), Vec::new()).await?);
bridge_process_at_least_one(&br).await;

while dc0.buffered_amount() > 0 {
Expand Down Expand Up @@ -535,7 +535,7 @@ async fn test_stats() -> Result<()> {
let dc0 = DataChannel::dial(&a0, 100, cfg.clone()).await?;
bridge_process_at_least_one(&br).await;

let dc1 = DataChannel::accept(&a1, Config::default()).await?;
let dc1 = DataChannel::accept(&a1, Config::default(), Vec::new()).await?;
bridge_process_at_least_one(&br).await;

let mut bytes_sent = 0;
Expand Down Expand Up @@ -628,7 +628,7 @@ async fn test_poll_data_channel() -> Result<()> {
let dc0 = Arc::new(DataChannel::dial(&a0, 100, cfg.clone()).await?);
bridge_process_at_least_one(&br).await;

let dc1 = Arc::new(DataChannel::accept(&a1, Config::default()).await?);
let dc1 = Arc::new(DataChannel::accept(&a1, Config::default(), Vec::new()).await?);
bridge_process_at_least_one(&br).await;

let mut poll_dc0 = PollDataChannel::new(dc0);
Expand Down
15 changes: 14 additions & 1 deletion src/data_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,25 @@ impl DataChannel {
}

/// Accept is used to accept incoming data channels over SCTP
pub async fn accept(association: &Arc<Association>, config: Config) -> Result<Self> {
pub async fn accept(
association: &Arc<Association>,
config: Config,
existing_channels: Vec<DataChannel>,
) -> Result<Self> {
let stream = association
.accept_stream()
.await
.ok_or(Error::ErrStreamClosed)?;

for channel in existing_channels.iter() {
if channel.stream_identifier() == stream.stream_identifier() {
channel
.stream
.set_default_payload_type(PayloadProtocolIdentifier::Binary);
return Ok(channel.to_owned());
}
}

stream.set_default_payload_type(PayloadProtocolIdentifier::Binary);

Self::server(stream, config).await
Expand Down