A simple yet fun simulation of a penalty shootout game built with ASP.NET Core, SignalR, and Redis. The project consists of two parts: a console application that simulates penalty shots with an amusing, ASCII-style display, and a web application (built with Razor Pages) that shows a live, realtime scoreboard.
-
Realtime Updates:
When a penalty results in a goal, the live view instantly updates the score via SignalR, so all connected clients see the latest results. -
Penalty Simulation in Console:
The console application simulates each penalty with a funny and dynamic display. The simulation includes random outcomes (goal, save, post, or miss) and an animated scene that mimics the motion of the ball and the goalkeeper. -
Backend Communication:
The game logic uses Redis as an in-memory datastore to track the score, ensuring fast and synchronized access between the console application and the web-based live view. -
Live Web View:
The web project, while admittedly minimal on the front-end (apologies for the weak UI—this was not the project’s main objective), provides a clear display of current scores and final results as the game unfolds.
-
Live (Web Application):
- SignalR Hub:
AGameHub
that handles two key events: updating the current score and broadcasting the final result. - Razor Pages & Views:
Basic pages that display live game scores and the final outcome. - Front-end:
Simple HTML, CSS, and JavaScript (using the SignalR client) for realtime updates. Please excuse the minimalist front-end design; styling wasn’t a core focus of this project.
- SignalR Hub:
-
Console Application:
- Game Logic:
Simulates penalty shots with randomized outcomes and fun ASCII animations. - Redis Integration:
Stores and updates scores in Redis, ensuring both the console simulation and live view remain synchronized. - SignalR Client:
Communicates with the web application’s SignalR hub to update score information in realtime.
- Game Logic:
-
Realtime Scoreboard:
Utilizes ASP.NET Core SignalR to deliver instant score updates to all connected clients. -
Dynamic Penalty Simulation:
The console application features a playful display for each penalty shot, making the simulation engaging and humorous. -
Redis for Fast Data Access:
Redis is used to store scores due to its excellent performance in handling realtime data and distributed caching scenarios. This ensures that score updates are swift and consistent across different parts of the system. -
Seamless Integration:
The combination of SignalR and Redis creates a robust solution for maintaining state and pushing updates instantly, demonstrating the power of realtime web applications.
-
SignalR for Realtime Communication:
SignalR is the backbone of the realtime functionality in this project. It allows the server to push updates directly to the client, ensuring that when a penalty is scored, the live view is immediately updated. This is crucial for any application where immediacy and responsiveness are key. -
Redis for Fast, In-Memory Data Storage:
Redis was chosen to track the game scores because of its ability to provide lightning-fast data access. In a realtime scenario like a live game simulation, ensuring that data is quickly available and consistent is paramount. Redis’ support for atomic operations (like incrementing scores) makes it a natural fit for this kind of application.
-
Realtime Application Enthusiasts:
Developers interested in building realtime web applications using ASP.NET Core and SignalR. -
Redis and Distributed Caching Fans:
Those looking to see how Redis can be leveraged for fast, synchronized state management in an interactive project. -
Game Simulation Hobbyists:
Anyone who enjoys simple game simulations and is curious about integrating console-based fun with a live web view. -
Learners and Educators:
Ideal for educational purposes or as a base project to demonstrate how different technologies (SignalR, Redis, Razor Pages) can work together.
For any questions or further discussions regarding SignalR, Redis, or any other aspect of this project, feel free to reach out via email.
*Email: [mnavaienezhad@gmail.com]
This project demonstrates how a lightweight game simulation can harness the power of realtime communication and fast data storage to create a dynamic and engaging user experience—even if the UI isn’t its strongest suit. Enjoy exploring and feel free to extend the project further!