Skip to content

Commit

Permalink
Update CODEOWNERS (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Ethan <[email protected]>
  • Loading branch information
cheukt and stuqdog authored Nov 21, 2022
1 parent 67781fa commit cde93d8
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 73 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* @npmenard @stuqdog
* @viamrobotics/sdk-netcode
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tower-http = { version = "0.3.3", features = ["add-extension","auth","propagate-
tracing = {version = "0.1.34"}
tracing-subscriber = {version = "0.3.11", features = ["env-filter"]}
webpki-roots = "0.21.1"
webrtc = "0.5.0"
webrtc = "0.6.0"


[build-dependencies]
Expand Down
6 changes: 2 additions & 4 deletions src/rpc/base_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ impl WebRTCBaseChannel {
pc.get_stats_id()
);
})
}))
.await;
}));

let channel = Arc::new(Self {
peer_connection,
Expand All @@ -70,8 +69,7 @@ impl WebRTCBaseChannel {
log::error!("error closing channel: {e}")
}
})
}))
.await;
}));

channel
}
Expand Down
28 changes: 13 additions & 15 deletions src/rpc/client_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,20 @@ impl WebRTCClientChannel {
let ret_channel = channel.clone();
let channel = Arc::downgrade(&channel);

data_channel
.on_message(Box::new(move |msg: DataChannelMessage| {
let channel = channel.clone();
Box::pin(async move {
let channel = match channel.upgrade() {
Some(channel) => channel,
None => {
return;
}
};
if let Err(e) = channel.on_channel_message(msg).await {
log::error!("error deserializing message: {e}");
data_channel.on_message(Box::new(move |msg: DataChannelMessage| {
let channel = channel.clone();
Box::pin(async move {
let channel = match channel.upgrade() {
Some(channel) => channel,
None => {
return;
}
})
}))
.await;
};
if let Err(e) = channel.on_channel_message(msg).await {
log::error!("error deserializing message: {e}");
}
})
}));
log::debug!("Client channel created");
ret_channel
}
Expand Down
20 changes: 9 additions & 11 deletions src/rpc/dial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,10 @@ async fn maybe_connect_via_webrtc(
let uuid_for_ice_gathering_thread = uuid_lock.clone();
let is_open = Arc::new(AtomicBool::new(false));
let is_open_read = is_open.clone();
data_channel
.on_open(Box::new(move || {
is_open.store(true, Ordering::Release);
Box::pin(async move {})
}))
.await;
data_channel.on_open(Box::new(move || {
is_open.store(true, Ordering::Release);
Box::pin(async move {})
}));

let exchange_done = Arc::new(AtomicBool::new(false));
let remote_description_set = Arc::new(AtomicBool::new(false));
Expand All @@ -514,8 +512,8 @@ async fn maybe_connect_via_webrtc(

let exchange_done = exchange_done.clone();
let remote_description_set = remote_description_set.clone();
peer_connection
.on_ice_candidate(Box::new(move |ice_candidate: Option<RTCIceCandidate>| {
peer_connection.on_ice_candidate(Box::new(
move |ice_candidate: Option<RTCIceCandidate>| {
let remote_description_set = remote_description_set.clone();
if exchange_done.load(Ordering::Acquire) {
return Box::pin(async move {});
Expand Down Expand Up @@ -569,8 +567,8 @@ async fn maybe_connect_via_webrtc(
}
}
})
}))
.await;
},
));

peer_connection.set_local_description(offer).await?;
}
Expand Down Expand Up @@ -739,7 +737,7 @@ async fn maybe_connect_via_webrtc(
}

async fn ice_candidate_to_proto(ice_candidate: RTCIceCandidate) -> Result<IceCandidate> {
let ice_candidate = ice_candidate.to_json().await?;
let ice_candidate = ice_candidate.to_json()?;
Ok(IceCandidate {
candidate: ice_candidate.candidate,
sdp_mid: ice_candidate.sdp_mid,
Expand Down
80 changes: 38 additions & 42 deletions src/rpc/webrtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,17 @@ pub(crate) async fn new_peer_connection_for_client(
..Default::default()
};

peer_connection
.on_peer_connection_state_change(Box::new(move |connection: RTCPeerConnectionState| {
peer_connection.on_peer_connection_state_change(Box::new(
move |connection: RTCPeerConnectionState| {
log::info!("peer connection state change: {connection}");
Box::pin(async move {})
}))
.await;
},
));

peer_connection
.on_signaling_state_change(Box::new(move |ssc: RTCSignalingState| {
log::info!("new signaling state: {ssc}");
Box::pin(async move {})
}))
.await;
peer_connection.on_signaling_state_change(Box::new(move |ssc: RTCSignalingState| {
log::info!("new signaling state: {ssc}");
Box::pin(async move {})
}));

let data_channel = peer_connection
.create_data_channel("data", Some(data_channel_init))
Expand All @@ -237,39 +235,37 @@ pub(crate) async fn new_peer_connection_for_client(
let nc = negotiation_channel.clone();
let pc = Arc::downgrade(&peer_connection);

negotiation_channel
.on_message(Box::new(move |msg: DataChannelMessage| {
let wpc = pc.clone();
let nc = nc.clone();
Box::pin(async move {
let pc = match wpc.upgrade() {
Some(pc) => pc,
None => return,
};
let sdp_vec = msg.data.to_vec();
let maybe_err = async move {
let sdp = serde_json::from_slice::<RTCSessionDescription>(&sdp_vec)
.map_err(create_invalid_sdp_err)?;
pc.set_remote_description(sdp).await?;
let answer = pc.create_answer(None).await?;
pc.set_local_description(answer).await?;
let local_description = pc
.local_description()
.await
.ok_or("No local description set");
let desc =
serde_json::to_vec(&local_description).map_err(create_invalid_sdp_err)?;
let desc = Bytes::copy_from_slice(&desc);
nc.send(&desc).await
}
.await;
negotiation_channel.on_message(Box::new(move |msg: DataChannelMessage| {
let wpc = pc.clone();
let nc = nc.clone();
Box::pin(async move {
let pc = match wpc.upgrade() {
Some(pc) => pc,
None => return,
};
let sdp_vec = msg.data.to_vec();
let maybe_err = async move {
let sdp = serde_json::from_slice::<RTCSessionDescription>(&sdp_vec)
.map_err(create_invalid_sdp_err)?;
pc.set_remote_description(sdp).await?;
let answer = pc.create_answer(None).await?;
pc.set_local_description(answer).await?;
let local_description = pc
.local_description()
.await
.ok_or("No local description set");
let desc =
serde_json::to_vec(&local_description).map_err(create_invalid_sdp_err)?;
let desc = Bytes::copy_from_slice(&desc);
nc.send(&desc).await
}
.await;

if let Err(e) = maybe_err {
log::error!("Error processing sdp in negotiation channel: {e}");
}
})
}))
.await;
if let Err(e) = maybe_err {
log::error!("Error processing sdp in negotiation channel: {e}");
}
})
}));

if disable_trickle_ice {
let offer = peer_connection.create_offer(None).await?;
Expand Down

0 comments on commit cde93d8

Please sign in to comment.