Skip to content

Sandstorm831/chessSocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chess-Socket

Chess-Socket is an open-source Socket.IO server for chessdom.

Table of Contents

  1. About The Project
  2. Prerequisites
  3. Built with
  4. Installation
  5. Project structure
  6. Note
  7. License

About The Project

Chess-Socket is an open-source socket-io server primarily made for the chessdom project live chess game-play functionality. It maintains the state of game for reconciliation in case of accidental disconnects. It'll recursively sent the responses untill it recieve a acknowledgement from the respective client.

Built With

Socket.IO Prisma NodeJS TypeScript

Prerequisites

To run the project in your local machine, you must have

Installation

Once you finish installation Node.js, follow the commands to setup the project locally on your machine

  1. clone the project

    git clone https://github.com/Sandstorm831/chessSocket.git
  2. enter the project

    cd chessSocket
  3. Install NPM packages

    npm install
  4. Create .env file at the root of the folder.

    touch .env
  5. Setup the DATABASE_URL in .env file

    DATABASE_URL=

    You can get a hosted SQL database from Aiven

  6. Establish link between schema.prisma and .env

    npx prisma generate
  7. Apply the migrations to the DB.

    npx prisma migrate deploy
  8. build the project

    npm run build
  9. Start the server

     npm run start

    This completes the set-up for this project, all the functionalities present in the application will now be live at port: 8080, remember to bypass CORS setting present in the server.ts file to connect to a localhost.

Project Structure

chessSocket
┃
┣ prisma
┃ ┣ migrations                              // various migrations files
┃ ┃ ┃                                       // for DB schema
┃ ┃ ┣ 20250206074038_init
┃ ┃ ┃ ┗ migration.sql
┃ ┃ ┣ 20250206074554_pgn_long_string
┃ ┃ ┃ ┗ migration.sql
┃ ┃ ┣ 20250206075112_storing_pgs_as_text
┃ ┃ ┃ ┗ migration.sql
┃ ┃ ┗ migration_lock.toml
┃ ┗ schema.prisma                           // DB schema
┃
┣ src
┃ ┣ websockets
┃ ┃ ┗ server.ts                             // Complete web-socket server
┃ ┣ DBQueries.ts                            // All DB queries definition
┃ ┗ queue.ts                                // Custom Queue data structure
┃
┣ .gitignore
┣ README.md
┣ package-lock.json
┣ package.json
┣ tsconfig.json
┗ tsconfig.tsbuildinfo

Note

  • Server will Ban any user, from whom any unexpected response came back to the server. The ban last for 15 minures
  • Server maintains the state of game, thus for any accidental disconnects, the original game will be restored if the game exists and user joins before 10 seconds
  • A valid game end will prompt the server to save the game to database automatically, any valid game ending includes resignation, checkmate or draw
  • Any user leaving in between the game, is dealt by prompting the same to the opponent user
  • Rematch functionality is also given, therefore, if both users clicks rematch a rematch will start immediately

License

Distributed under the GPL-3.0 license. See LICENSE for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors