We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a8245bd commit d83d33cCopy full SHA for d83d33c
examples/webrtc_datachannel/src/lib.rs
@@ -74,7 +74,12 @@ pub async fn start() -> Result<(), JsValue> {
74
dc2.set_onmessage(Some(onmessage_callback.as_ref().unchecked_ref()));
75
onmessage_callback.forget();
76
77
- dc2.send_with_str("Ping from pc2.dc!").unwrap();
+ let dc2_clone = dc2.clone();
78
+ let onopen_callback = Closure::wrap(Box::new(move || {
79
+ dc2_clone.send_with_str("Ping from pc2.dc!").unwrap();
80
+ }) as Box<dyn FnMut()>);
81
+ dc2.set_onopen(Some(onopen_callback.as_ref().unchecked_ref()));
82
+ onopen_callback.forget();
83
}) as Box<dyn FnMut(RtcDataChannelEvent)>);
84
pc2.set_ondatachannel(Some(ondatachannel_callback.as_ref().unchecked_ref()));
85
ondatachannel_callback.forget();
0 commit comments