Skip to content

Commit

Permalink
Fix compiling in wasm (#671)
Browse files Browse the repository at this point in the history
  • Loading branch information
mvlabat authored Oct 11, 2024
1 parent d3146a7 commit 0b7a485
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lightyear/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mock_time = ["dep:mock_instant"]
webtransport = [
"dep:wtransport",
"dep:xwt-core",
"dep:xwt-web-sys",
"dep:xwt-web",
"dep:web-sys",
"dep:ring",
"dep:wasm-bindgen-futures",
Expand Down Expand Up @@ -171,7 +171,7 @@ getrandom = { version = "0.2.11", features = [
"js", # feature 'js' is required for wasm
] }
xwt-core = { version = "0.5", optional = true }
xwt-web-sys = { version = "0.13", optional = true }
xwt-web = { version = "0.13.0", optional = true }
wasm-bindgen = { version = "0.2.90", optional = true }
wasm-bindgen-futures = { version = "0.4.42", optional = true }
# compression
Expand Down
14 changes: 7 additions & 7 deletions lightyear/src/transport/webtransport/client_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ impl ClientTransportBuilder for WebTransportClientSocketBuilder {
&server_url
);

let options = xwt_web_sys::WebTransportOptions {
server_certificate_hashes: vec![xwt_web_sys::CertificateHash {
algorithm: xwt_web_sys::HashAlgorithm::Sha256,
let options = xwt_web::WebTransportOptions {
server_certificate_hashes: vec![xwt_web::CertificateHash {
algorithm: xwt_web::HashAlgorithm::Sha256,
value: ring::test::from_hex(&self.certificate_digest).unwrap(),
}],
..Default::default()
};
let endpoint = xwt_web_sys::Endpoint {
let endpoint = xwt_web::Endpoint {
options: options.to_js(),
};

Expand Down Expand Up @@ -118,7 +118,7 @@ impl ClientTransportBuilder for WebTransportClientSocketBuilder {
};
loop {
tokio::select! {
_ = wasm_bindgen_futures::JsFuture::from(connection.transport.closed()) => return,
_ = connection.transport.closed() => return,
to_send = connection.receive_datagram() => {
match to_send {
Ok(data) => {
Expand All @@ -139,7 +139,7 @@ impl ClientTransportBuilder for WebTransportClientSocketBuilder {
};
loop {
tokio::select! {
_ = wasm_bindgen_futures::JsFuture::from(connection.transport.closed()) => return,
_ = connection.transport.closed() => return,
recv = to_server_receiver.recv() => {
if let Some(msg) = recv {
trace!("send datagram to server: {:?}", &msg);
Expand All @@ -157,7 +157,7 @@ impl ClientTransportBuilder for WebTransportClientSocketBuilder {
};
// Wait for a close signal from the close channel, or for the quic connection to be closed
tokio::select! {
reason = wasm_bindgen_futures::JsFuture::from(connection.transport.closed()) => {
reason = connection.transport.closed() => {
info!("WebTransport connection closed. Reason: {reason:?}");
status_tx.send(ClientIoEvent::Disconnected(std::io::Error::other(format!("Error: {:?}", reason)).into())).await.unwrap();
},
Expand Down

0 comments on commit 0b7a485

Please sign in to comment.