Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cross native and wasm, ice trickle and data channel creation #54

Merged
merged 4 commits into from
Dec 17, 2022
Merged
Changes from 1 commit
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
1 change: 1 addition & 0 deletions matchbox_socket/src/webrtc_socket/mod.rs
Original file line number Diff line number Diff line change
@@ -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"))]
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
@@ -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(
@@ -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()
};

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
@@ -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(
@@ -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);