Giter VIP home page Giter VIP logo

xwt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xwt's Issues

Changing buffer size when reading from AsyncRead doesn't work

For example, by changing this test:

diff --git a/crates/xwt-tests/src/tests/tokio_io_read_small_buf.rs b/crates/xwt-tests/src/tests/tokio_io_read_small_buf.rs
index 889d318..6b0ad1b 100644
--- a/crates/xwt-tests/src/tests/tokio_io_read_small_buf.rs
+++ b/crates/xwt-tests/src/tests/tokio_io_read_small_buf.rs
@@ -39,7 +39,7 @@ where
 
     tokio::pin!(send_stream);
 
-    let mut to_write = &b"hello"[..];
+    let mut to_write = &b"hello!"[..];
     loop {
         let written = tokio::io::AsyncWriteExt::write(&mut send_stream, to_write)
             .await
@@ -66,16 +66,18 @@ where
         return Err(Error::BadData(read_buf));
     }
 
-    let read = tokio::io::AsyncReadExt::read(&mut recv_stream, &mut read_buf[..])
+    let mut read_buf_2 = vec![0u8; 3];
+
+    let read = tokio::io::AsyncReadExt::read(&mut recv_stream, &mut read_buf_2[..])
         .await
         .map_err(Error::Read)?;
     if read == 0 {
         return Err(Error::NoResponse);
     };
-    read_buf.truncate(read);
+    read_buf_2.truncate(read);
 
-    if read_buf != b"ll" {
-        return Err(Error::BadData(read_buf));
+    if read_buf_2 != b"llo" {
+        return Err(Error::BadData(read_buf_2));
     }
 
     let read = tokio::io::AsyncReadExt::read(&mut recv_stream, &mut read_buf[..])
@@ -86,7 +88,7 @@ where
     };
     read_buf.truncate(read);
 
-    if read_buf != b"o" {
+    if read_buf != b"!" {
         return Err(Error::BadData(read_buf));
     }

It now fails with:

panicked at crates/xwt-web-sys/tests/test.rs:97:10:
called `Result::unwrap()` on an `Err` value: BadData([108, 108])

Which seems to imply the internal buffer was not changed.

Making the second buffer smaller also fails, with:

panicked at crates/web-sys-async-io/src/reader.rs:64:39:
n overflows remaining

Incomplete chunk reading/writing for streams

Hi,

Thanks for making this library! I've been using xwt while developing a small WASM/native app and it's saved me a lot of time.

I see that there has been a start on supporting chunked reading/writing with the ReadChunk and WriteChunk traits in xwt-core, but it seems these are not implemented anywhere as of yet. (Am I missing something?)

What are the blockers for implementation of these traits within xwt-web-sys and xwt-wtransport?

I may be able to lend a hand.

What's the state of WASM support?

The library seems to have no examples, tests, or a README. Is this a side project or a serious attempt at supporting WASM client webtransport in Bevy?

To add, I'm interested in seeing where this goes. I'm an author of Matchbox (WebRTC) and bevy_rtc, but I'm in the market lately for a simpler network layer. WebRTC is becoming difficult to manage.

xwt_web_sys: accept_bi doesn't work

nertsio_ui.js:292 panicked at 'called `Result::unwrap()` on an `Err` value: JsValue(TypeError: Cannot read properties of undefined (reading 'getWriter')
TypeError: Cannot read properties of undefined (reading 'getWriter')

seems to be because it's trying to use the result from ReadableStreamDefaultReader#read() directly instead of grabbing value from the object

Enable documentation

The project is mature enough to enable the documentation - to explain the design behind the choices and trade-offs that were taken here.

Better IO traits (aka reader knowns when to stop)

The tokio's async read/write are great and all, but they fail to accurately capture a crucial detail: the WebTransport IO can communicate the EOF properly, as opposed to the zero-byte reads that are just bizarre.
I wonder how we got to the point where there's no common async I/O interface that would be sufficient for readers that know when to stop.

Reading from stream using AsyncRead doesn't work

(with xwt-web-sys)

e.g.

    let (mut send, mut recv) = connection
          .open_bi()
          .await
          .map_err(convert_error)?
          .wait_bi()
          .await?;

      send.write(b"test").await.map_err(convert_error)?;

      let mut buf = [0; 8];

      let amount = tokio::io::AsyncReadExt::read(&mut recv, &mut buf).await?;

      let value = &buf[..amount];

Fails with the error {} on reading.

Adding extra logging to web-sys-async-io, I was able to get this error instead:

TypeError: Failed to execute 'read' on 'ReadableStreamBYOBReader': parameter 1 is not of type 'ArrayBufferView'.
    at imports.wbg.__wbg_read_421ea09231f62999 (client.js:342:37)
    at web_sys::features::gen_ReadableStreamByobReader::ReadableStreamByobReader::read_with_array_buffer_view::h2d79409db104f874 (client_bg.wasm:0x192cf)
    at <web_sys_async_io::reader::Reader as tokio::io::async_read::AsyncRead>::poll_read::hc90cb112c785b849 (client_bg.wasm:0xc563)
    at <xwt_web_sys::RecvStream as tokio::io::async_read::AsyncRead>::poll_read::hfc44f7b8815e8db5 (client_bg.wasm:0x19294)
    at client::main::{{closure}}::haf584d15d6c74303 (client_bg.wasm:0x2561)
    at wasm_bindgen_futures::task::singlethread::Task::run::h0ab3b9ff943bdb36 (client_bg.wasm:0x15030)
    at wasm_bindgen_futures::queue::Queue::new::{{closure}}::h592219bb7764a2c3 (client_bg.wasm:0xf5c1)
    at wasm_bindgen::convert::closures::invoke1_mut::h00413c1a66bb61c2 (client_bg.wasm:0x18bc7)
    at __wbg_adapter_22 (client.js:208:10)
    at real (client.js:193:20)

Can not build WASM with Bevy

Thank you for your efforts to make this lib happen!

I am trying to play with experimenting xwebtransport with bevy, but unfortunately I can't build it into WASM and got this error:

image

Since I am already pull the lib and try to build and run all the test and it was successfully, I think it's some what I'm doing wrong with my Cargo.toml

Here is my Cargo.toml file:

image

I think I need to put any features flag? But I'm not found any features flag in your lib.
Do you have any suggestion?

Non-async API?

I want to use this crate on wasm32-unknown-emscripten but I see most of the API is async, and in emscripten, futures are not supported (well there is a compile flag called ASYNCIFY, but I've never gotten it work work, but that's outside of scope for this discussion). So I am hoping theres a way to use xwt without async. Thanks for your help!

bevy_xwt

Hey,

When doing my exploration into #132 - I found that I would indeed benefit from an API akin to bevy_matchbox

I want to start building bevy_xwt, at a high level:

bevy_xwt: 2 features (client, server)

  • client:
    • commands:
      • commands.start_session(url: &str)
      • commands.close_session()
    • system parameters:
      • ClientSession, derefs to Session
    • events:
      • enum ClientEvent { IdAssigned(SessionId), Connected, Disconnected }
  • server:
    • commands:
      • commands.start_server(port: u16)
      • commands.stop_server()
    • system parameters:
      • ServerSessions, derefs to HashMap<SessionId, Session>
    • events:
      • enum ServerEvent { ClientJoined(SessionId), ClientLeft(SessionId) }

That's basically it, extremely simple to start.

Since you mentioned you want to reserve the name bevy_xwt, do you mind starting the seed repo, and adding me as a contributor so I can continue to build it under your repo?

Question: How to manage connection?

xwebtransport is working fine with WASM and Native.

I have question that how do we manage connection (ex: connection lost, route trip time) ?

In wtransport crate, they have closed and rtt function for manage connection, but xwebtransport not expose/implement that feature for WASM

Am I missing something?

Datagram buffer size issues

Something's off with datagram buffer sizes in wasm; probably a simple fix, but first an investigation of what and why is happening in needed. And a test case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.