Skip to content

Commit cde93d8

Browse files
cheuktstuqdog
andauthored
Update CODEOWNERS (#11)
Co-authored-by: Ethan <[email protected]>
1 parent 67781fa commit cde93d8

File tree

6 files changed

+64
-73
lines changed

6 files changed

+64
-73
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
* @npmenard @stuqdog
2+
* @viamrobotics/sdk-netcode

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tower-http = { version = "0.3.3", features = ["add-extension","auth","propagate-
4343
tracing = {version = "0.1.34"}
4444
tracing-subscriber = {version = "0.3.11", features = ["env-filter"]}
4545
webpki-roots = "0.21.1"
46-
webrtc = "0.5.0"
46+
webrtc = "0.6.0"
4747

4848

4949
[build-dependencies]

src/rpc/base_channel.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ impl WebRTCBaseChannel {
4949
pc.get_stats_id()
5050
);
5151
})
52-
}))
53-
.await;
52+
}));
5453

5554
let channel = Arc::new(Self {
5655
peer_connection,
@@ -70,8 +69,7 @@ impl WebRTCBaseChannel {
7069
log::error!("error closing channel: {e}")
7170
}
7271
})
73-
}))
74-
.await;
72+
}));
7573

7674
channel
7775
}

src/rpc/client_channel.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,20 @@ impl WebRTCClientChannel {
7575
let ret_channel = channel.clone();
7676
let channel = Arc::downgrade(&channel);
7777

78-
data_channel
79-
.on_message(Box::new(move |msg: DataChannelMessage| {
80-
let channel = channel.clone();
81-
Box::pin(async move {
82-
let channel = match channel.upgrade() {
83-
Some(channel) => channel,
84-
None => {
85-
return;
86-
}
87-
};
88-
if let Err(e) = channel.on_channel_message(msg).await {
89-
log::error!("error deserializing message: {e}");
78+
data_channel.on_message(Box::new(move |msg: DataChannelMessage| {
79+
let channel = channel.clone();
80+
Box::pin(async move {
81+
let channel = match channel.upgrade() {
82+
Some(channel) => channel,
83+
None => {
84+
return;
9085
}
91-
})
92-
}))
93-
.await;
86+
};
87+
if let Err(e) = channel.on_channel_message(msg).await {
88+
log::error!("error deserializing message: {e}");
89+
}
90+
})
91+
}));
9492
log::debug!("Client channel created");
9593
ret_channel
9694
}

src/rpc/dial.rs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,10 @@ async fn maybe_connect_via_webrtc(
494494
let uuid_for_ice_gathering_thread = uuid_lock.clone();
495495
let is_open = Arc::new(AtomicBool::new(false));
496496
let is_open_read = is_open.clone();
497-
data_channel
498-
.on_open(Box::new(move || {
499-
is_open.store(true, Ordering::Release);
500-
Box::pin(async move {})
501-
}))
502-
.await;
497+
data_channel.on_open(Box::new(move || {
498+
is_open.store(true, Ordering::Release);
499+
Box::pin(async move {})
500+
}));
503501

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

515513
let exchange_done = exchange_done.clone();
516514
let remote_description_set = remote_description_set.clone();
517-
peer_connection
518-
.on_ice_candidate(Box::new(move |ice_candidate: Option<RTCIceCandidate>| {
515+
peer_connection.on_ice_candidate(Box::new(
516+
move |ice_candidate: Option<RTCIceCandidate>| {
519517
let remote_description_set = remote_description_set.clone();
520518
if exchange_done.load(Ordering::Acquire) {
521519
return Box::pin(async move {});
@@ -569,8 +567,8 @@ async fn maybe_connect_via_webrtc(
569567
}
570568
}
571569
})
572-
}))
573-
.await;
570+
},
571+
));
574572

575573
peer_connection.set_local_description(offer).await?;
576574
}
@@ -739,7 +737,7 @@ async fn maybe_connect_via_webrtc(
739737
}
740738

741739
async fn ice_candidate_to_proto(ice_candidate: RTCIceCandidate) -> Result<IceCandidate> {
742-
let ice_candidate = ice_candidate.to_json().await?;
740+
let ice_candidate = ice_candidate.to_json()?;
743741
Ok(IceCandidate {
744742
candidate: ice_candidate.candidate,
745743
sdp_mid: ice_candidate.sdp_mid,

src/rpc/webrtc.rs

Lines changed: 38 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,17 @@ pub(crate) async fn new_peer_connection_for_client(
213213
..Default::default()
214214
};
215215

216-
peer_connection
217-
.on_peer_connection_state_change(Box::new(move |connection: RTCPeerConnectionState| {
216+
peer_connection.on_peer_connection_state_change(Box::new(
217+
move |connection: RTCPeerConnectionState| {
218218
log::info!("peer connection state change: {connection}");
219219
Box::pin(async move {})
220-
}))
221-
.await;
220+
},
221+
));
222222

223-
peer_connection
224-
.on_signaling_state_change(Box::new(move |ssc: RTCSignalingState| {
225-
log::info!("new signaling state: {ssc}");
226-
Box::pin(async move {})
227-
}))
228-
.await;
223+
peer_connection.on_signaling_state_change(Box::new(move |ssc: RTCSignalingState| {
224+
log::info!("new signaling state: {ssc}");
225+
Box::pin(async move {})
226+
}));
229227

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

240-
negotiation_channel
241-
.on_message(Box::new(move |msg: DataChannelMessage| {
242-
let wpc = pc.clone();
243-
let nc = nc.clone();
244-
Box::pin(async move {
245-
let pc = match wpc.upgrade() {
246-
Some(pc) => pc,
247-
None => return,
248-
};
249-
let sdp_vec = msg.data.to_vec();
250-
let maybe_err = async move {
251-
let sdp = serde_json::from_slice::<RTCSessionDescription>(&sdp_vec)
252-
.map_err(create_invalid_sdp_err)?;
253-
pc.set_remote_description(sdp).await?;
254-
let answer = pc.create_answer(None).await?;
255-
pc.set_local_description(answer).await?;
256-
let local_description = pc
257-
.local_description()
258-
.await
259-
.ok_or("No local description set");
260-
let desc =
261-
serde_json::to_vec(&local_description).map_err(create_invalid_sdp_err)?;
262-
let desc = Bytes::copy_from_slice(&desc);
263-
nc.send(&desc).await
264-
}
265-
.await;
238+
negotiation_channel.on_message(Box::new(move |msg: DataChannelMessage| {
239+
let wpc = pc.clone();
240+
let nc = nc.clone();
241+
Box::pin(async move {
242+
let pc = match wpc.upgrade() {
243+
Some(pc) => pc,
244+
None => return,
245+
};
246+
let sdp_vec = msg.data.to_vec();
247+
let maybe_err = async move {
248+
let sdp = serde_json::from_slice::<RTCSessionDescription>(&sdp_vec)
249+
.map_err(create_invalid_sdp_err)?;
250+
pc.set_remote_description(sdp).await?;
251+
let answer = pc.create_answer(None).await?;
252+
pc.set_local_description(answer).await?;
253+
let local_description = pc
254+
.local_description()
255+
.await
256+
.ok_or("No local description set");
257+
let desc =
258+
serde_json::to_vec(&local_description).map_err(create_invalid_sdp_err)?;
259+
let desc = Bytes::copy_from_slice(&desc);
260+
nc.send(&desc).await
261+
}
262+
.await;
266263

267-
if let Err(e) = maybe_err {
268-
log::error!("Error processing sdp in negotiation channel: {e}");
269-
}
270-
})
271-
}))
272-
.await;
264+
if let Err(e) = maybe_err {
265+
log::error!("Error processing sdp in negotiation channel: {e}");
266+
}
267+
})
268+
}));
273269

274270
if disable_trickle_ice {
275271
let offer = peer_connection.create_offer(None).await?;

0 commit comments

Comments
 (0)