Skip to content

Commit

Permalink
constant for data channel id
Browse files Browse the repository at this point in the history
  • Loading branch information
rozgo committed Dec 16, 2022
1 parent 3737f20 commit 079cd51
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions matchbox_socket/src/webrtc_socket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod messages;
mod signal_peer;

const KEEP_ALIVE_INTERVAL: u64 = 10_000;
const DATA_CHANNEL_ID: u16 = 124;

// TODO: maybe use cfg-if to make this slightly tidier
#[cfg(not(target_arch = "wasm32"))]
Expand Down
4 changes: 2 additions & 2 deletions matchbox_socket/src/webrtc_socket/native/message_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use webrtc::{
use crate::webrtc_socket::{
messages::{PeerEvent, PeerId, PeerRequest, PeerSignal},
signal_peer::SignalPeer,
Packet, WebRtcSocketConfig, KEEP_ALIVE_INTERVAL,
Packet, WebRtcSocketConfig, DATA_CHANNEL_ID, KEEP_ALIVE_INTERVAL,
};

pub async fn message_loop(
Expand Down Expand Up @@ -426,7 +426,7 @@ async fn create_data_channel(
let config = RTCDataChannelInit {
ordered: Some(false),
max_retransmits: Some(0),
negotiated: Some(124),
negotiated: Some(DATA_CHANNEL_ID),
..Default::default()
};

Expand Down
5 changes: 2 additions & 3 deletions matchbox_socket/src/webrtc_socket/wasm/message_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@ use web_sys::{
RtcIceCandidate, RtcIceCandidateInit, RtcPeerConnection, RtcSdpType, RtcSessionDescriptionInit,
};

use crate::webrtc_socket::KEEP_ALIVE_INTERVAL;
use crate::webrtc_socket::{
messages::{PeerEvent, PeerId, PeerRequest, PeerSignal},
signal_peer::SignalPeer,
Packet, WebRtcSocketConfig,
Packet, WebRtcSocketConfig, DATA_CHANNEL_ID, KEEP_ALIVE_INTERVAL,
};

pub async fn message_loop(
Expand Down Expand Up @@ -416,7 +415,7 @@ fn create_data_channel(
data_channel_config.ordered(false);
data_channel_config.max_retransmits(0);
data_channel_config.negotiated(true);
data_channel_config.id(124);
data_channel_config.id(DATA_CHANNEL_ID);

let channel: RtcDataChannel =
connection.create_data_channel_with_data_channel_dict("webudp", &data_channel_config);
Expand Down

0 comments on commit 079cd51

Please sign in to comment.