This is a client-server multiplayer desktop game made using C#. It was a collaboration with my colleague on our school project. The main purpose of project was to learn about sockets, asynchronous programming, threads and client-server architecture.
There is a Server
which must be started before starting the game. At a startup a new C# Task
is made to listen for connection requests. After the request is received the whole communication between server and client is transfered to new thread - ClientHandler
ClientHandler
contains method called ProcessRequests
which is responsible for whole communication with particular client. It waits for Request
s and based on enum OperationRequest
it serves the request.
On the other hand, when new user clicks play button, a Task
is being created on client side which has method to listen for Response
s from server and based enum OperationResponse
it takes further actions.
As we can see, the whole communication is based on requests from clients (they are generated by user interaction with GUI) and responses from server.
The game contains fully functional lobby where people can see other players waiting for game. Anyone can create game and wait to be challenged. When someone is waiting for game it is displayed to all users instantly. Challenges can be accepted or declined. When user which created game accepts challenge, the game starts.
When the game starts the whole communication is transfered to GameHandler
which is on server side responsible for communication with both clients
Roll a Dice game
- it's a turn based game where one player rolls a dice until he gets One or until he holds. It's a risk because every time player gets One their current score in that round goes to zero. Every turn is a risk! Player who first comes to 30 wins and and carries over 20 points to the next game.
Trivia Game
- it's a simple quiz with IT questions where players have 10 seconds to answer. Speed matters! First who answers, if the answer is true gets 5p, if the answer is false player loses 3p and the other player has a 5 seconds to answer if he wants.
1. Currently the game can be runned on be locally.
2. We used Entity framework as ORM to design database tables, but we are not satisfied with database design (although there wasn't great need for database at all)
C# 10.0
Entity Framework Core 6.0
SQL Server
.NET 4.8