Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimum core changes required for compiling Eventwork to WASM and allowing other NetworkProviders to support WASM #10

Merged
merged 3 commits into from
Nov 22, 2023

Conversation

NoahShomette
Copy link
Collaborator

@NoahShomette NoahShomette commented Nov 12, 2023

NOTE: This should be merged following #9 . When that happens I will clean this merge up to accurately represent only the minimum changes required

Changes

  • Update NetworkProvider trait to be non-send in Wasm32 contexts
  • Added a new function to the Runtime trait, spawn_local. This returns a non-send future instead of a send future.
  • Added a run_async function that has two variants that are conditionally compiled based on the wasm context or not. In wasm it calls the runtimes spawn_local, otherwise it calls the same spawn.
  • Made the Network manager call run_async instead of calling runtime.spawn directly whenever it was calling that
  • Updated the Runtime functions to conditionally return None in wasm context. This is due to Task becoming FakeTask in singlethreaded contexts which is not public and doesn't actually do anything in the first place.
  • Added a new NetworkError type, Error. Needed as a generic error to support converting other foreign errors into some type of returnable error in the NetworkProvider trait.

With the above changes and a new NetworkProvider thats not TCP, the crate can compile and run successfully on WASM.

If you'd like to test this patch you can check this crate and run the server and then the wasm_client_example using trunk

@NoahShomette NoahShomette marked this pull request as ready for review November 21, 2023 04:44
@NoahShomette
Copy link
Collaborator Author

@jamescarterbell As promised this is all cleaned up and passing CI. I verified it using my websocket transport that it is working in wasm still.

I think it should be good to go!

@jamescarterbell jamescarterbell merged commit 48cfba0 into jamescarterbell:main Nov 22, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants