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

[DRAFT!] Multiplayer with Blazor Server #193

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

lachlanwgordon
Copy link
Contributor

This is very much a work in progress but I thought I'd share it as a draft PR for anyone interested in my progress.

I've successfully got Blazing Trains running in Blazor WASM inside a Blazor server site. I've got shared memory managed on the server and interop that sends data into the wasm runtime to update data in the game.

You can try it out at https://blazingservertrains.azurewebsites.net/

Here's trains running on three different devices at once. When I enter a number for the terrain seed in thje text field all three devices update.
2021-11-12 23 10 32

Next step will be architecting the interop a little better and then shared track layout.

Notes about the gif above

  • The window on the right is a VM running on Azure with no GPU, middle is my Mac Book Pro, left is a Pixel 3A device on the same wifi as the mac
  • VM and Azure App service are both Australia South East
  • When I edi tthe seed in VM, the mac updates the fastest, followed by VM, then a few seconds later the Pixel. This suggests that network latency is neglible here and the update time is CPU/GPU bound.
  • I haven't merged in your code lately so I don't think this is AOT

It's hooked up to run multiple startup projects, it'll work better with a project reference instead.
This is done with a project reference to the wasm hosting the static files
I've got some shared state between instances of the page but not passing into the wasm yet
add a github action generated by the right click publish dialogue. That's pretty cool.
I can pass a message entered by the user in  Blazor server all the way through javascript and into WASM world and put it on the page
@davidwengier
Copy link
Owner

Interesting. Piggy back-ing on blazor servers signalr connection to share data like this is definitely interesting, and in theory the solution could actually be "simple" - have ILayout and IMovableLayout implementations on the server that get picked up by DI instead of the ones in Trains.Net.Engine, and they do the JSInterop thing, and the rest is hisotry.

Though of course that would mean mixing my DI and ASP.NET Core's DI, and that is probably the hardest part 😁

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