With this project I had to create a messaging app using .NET Framework and the Transmission Control Protocol Model, which had an integrated Tic Tac Toe game. Data was to be stored in a database for use of user login information and game specific data (wins, losses, draws etc.)
The program was comprised of 5 .cs scripts;
TCPChatBase.cs – the base script which our clients and server will inherit from. It handles window specific operations and chatting functions
ClientSocket.cs – This class is used to handle all client-specific data such as state, username, message data etc. The script is using System.Net.Sockets to access the .NET core socket
TCPChatServer.cs – Inherits from TCPChatBase, this handles all the server operations and functions such as; handling client commands, handling the state of tic tac toe game, passing messages through & database changes. All DB functionality is maintained here after the SQL nuget package was installed to my project.
TCPChatClient.cs – Inherits from TCPChatBase. Once a server is started, the client window can attempt connection and send messages to the server, which are relayed to other clients.
TicTacToe.cs – this script handled the game of tic-tac-toe logic
Below are some screens on the classes and their functions…
Give it a try!
<< Link to Project >>
Functionality
Short of being able to chat with other connected clients and play tic tac toe, a number of other commands were made available. Some have been iterated upon, others have been removed with upgrades to the project.
The Server, or HOST, is able to allocate “Moderators” using the secret command ‘!mod [client_username]’, this would then allow that user to then disconnect other clients at will. but with great power, comes great chance of being a pain in the @%$.
Two clients are able to “!join” the play board to enjoy some Tic-Tac-Toe. Once they’ve been allowed by the server to interact with the game board, they take turns in the masterfully tactful game of Tic-Tac-Toe.
I was also asked to implement a Command of my own choosing, so in sticking to the theme of retro, I implemented a Magic 8 Ball feature where clients could ask the server a question, to which it would respond in 1 of 19 ways, and depending on their tone, will notify other clients how fortuitous the asker was.
Check out the Source Code or browse my other stuff on GitHub… Thanks!
☜(⌒▽⌒)☞