Node.js server that uses Express and Socket.io libraries to create a real-time multiplayer game server. Connects players and redirects moves made in the frontend. Frontend repository can be found here.
The server uses Express to handle HTTP requests, and Socket.io to handle real-time communication between clients and the server.
For logging the server uses Winston logger.
| Endpoint | Use |
|---|---|
'connection' |
Connect player to backend when application is opened |
'checkReconnect' |
Check if player has a game going on |
'boardData' |
Send board data to reconnected player |
'reconnectRequst' |
Player wants to reconnect to game |
'createLobby' |
Creates a new lobby |
'joinroom' |
Join room inside socket |
'joinlobby' |
Takes lobbyId as parameter and tries to find and connect player to that lobby |
'getLobbies' |
Returns all lobbies |
'getLobby' |
Get a single lobby data by id |
'joinqueue' |
Player can join a queue and when there are two players in queue they are connected to game |
'chat-message' |
Emits chat messages from player to chatbox |
'leaveQueue' |
Player has left from queue |
'boardOpened' |
Checks that both players have board open and emits event when they have |
'disconnect' |
Notify the other player if the opponent disconnects from the server |
'playerExited' |
Notify the other player if the opponent exits the game |
'gameOver' |
Deletes the lobby when game is over |
git clone https://github.com/OP2-CheckMate/OnlineChessBack.gitnpm installnpm run devnpm startctrl + c