Coder Social home page Coder Social logo

alexyakunin / boardgames Goto Github PK

View Code? Open in Web Editor NEW
71.0 7.0 8.0 520 KB

New Stl.Fusion sample and a fully functional web app allowing you to play real-time multiplayer board games. Powered by Stl.Fusion, Blazor, and .NET 5.

License: MIT License

Batchfile 0.38% Dockerfile 0.74% C# 71.26% HTML 27.19% CSS 0.42% JavaScript 0.01%
board-games blazor-wasm-mode blazor-server wasm real-time game game-development game-engine webassembly webassembly-demo signalr

boardgames's Introduction

BoardGames

"Board Games" is a Fusion sample and a fully functional web app allowing you to play real-time multiplayer board games.

Note: this repository wasn't updated for a while, so it uses an outdated version of Fusion (v1.3.x, while the current one is v3.7.x). Nevertheless it's still a good example you can play with to learn Fusion. The APIs change, but concepts stay the same :)

Live version of this app: https://boardgames.alexyakunin.com/

A short video explaining what's unique there:

The sample implements a number of features that are hard to implement without Fusion. In particular, you might notice that real-time state sync works literally everywhere in it. Try opening the sample in two different browsers, sign in using different user accounts, and:

  • Create and play a game in both windows
  • Check out what happens with game lists when you're creating a game, making moves, or posting a chat message
  • Try renaming your user & see its name changes everywhere - even in chat mentions!

What's implemented in Board Games

  • Two games. I plan to add a couple more a bit later - there is a common base API allowing to add new games pretty quickly
  • Game lobby, where you can track the state of games you participate in, browse open games created by other users and join them
  • Game chat, which supports mentions. In reality, there is an extendable message parser and modular renderer that supports user and game mentions.
  • User online/offline status tracking. Notice that every user badge displays it.
  • User profile page, where you can edit your user name, add MS/GitHub accounts, see all browser sessions, "kick" some of them or sign out from all of them.
  • Full state persistence to any DB supported by EF Core
  • Web API - it's used when the sample works in Blazor WASM mode, so whatever UI can do is available there too.

Finally, the sample supports both Blazor Server and Blazor WebAssembly modes.

The live version of this app is hosted on Google Cloud GKE:

Ok, real-time. But seriously, what's so new there?

The implementation cost of real-time updates. Everything you see there required me to write just 35 extra lines of code!

  • First 3 if blocks have ~ 15 lines of code inside
  • The last one (in GameService.cs, the invalidation logic is outside of an if clause there) has ~ 20 more.

And if you look at everything else, it's absolutely usual code you'd have otherwise too.

More precisely, you'd need at least this "everything else" to implement a non-real-time version of the same sample that supports just Blazor Server.

WASM version would require way more - the approach used in this sample, where server-side services are replaced by their client-side caching replicas (so-called "Replica Services" in Fusion terms) simply won't work without Fusion-style distributed version of "computed observable" that eliminates every RPC call known to return the same result as the locally cached one.

In other words, if you use Fusion, Blazor WASM mode has virtually zero implementation cost as well.

And this is what allowed me build Board Games single-handedly in 9 days. Proof: the very first commit cloning Fusion's Blazorise template was made on Feb 1, and I wrote this README describing what's already done on Feb 10 (though at that point there was just one game).

Looks interesting, how do I learn more about Fusion?

Check out Fusion and its other samples; join our Discord Server to ask questions.

P.S. I am sure there are some bugs - if you'll find one, please report an issue!

boardgames's People

Contributors

alexyakunin avatar

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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar

boardgames's Issues

[BUG] Unhandled exception. Npgsql.NpgsqlException (0x80004005): Exception while connecting

What I did to try and fix this:
Edited app_release's settings to be like this
docker_out.log

    ports:
     - "8080:8080"
    environment:
      ASPNETCORE_URLS: "http://*:8080"
      HTTPS_PORT: 4430

docker compose down && docker compose up --build app_release

I checked via sudo lsof -i -P -n | grep :5432, sudo lsof -i -P -n | grep :8080 and sudo lsof -i -P -n | grep :4430 that the ports are not already in use.

The full log is attached.
FYI: I'm running this on an Quasi-Ubuntu VM (Pop OS Virtualbox), docker by itself seems to work, tested by successful run of docker run hello-world.
The same exact issue also occurs when trying to run app_debug instead of app_release.

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.