-
Notifications
You must be signed in to change notification settings - Fork 16
Chess Server Service
The server listens to a variety of messages from our web sockets. Here are the messages the server looks for and how the server responds to those messages.
New Game
As one would imagine the server creates a new chess game between the mentor and student. This is achieved by sending a starting chess FEN to both players, randomly determining who starts as black or white, and adding both players to an on going games data structure. The on going games data structure contains all games currently running on the server.
End Game
The end game message simply removes both players from the on going games data structure.
New State
The new state message tells the server one of the players made a move, so this move needs to be updated on the other users screen.
Create New Game
This message only differs from the new game message by not having to add the student and mentor to the ongoing games array. Both players simply receive a new chess game FEN and a random color(black or white).
Flip Board
This message flips the view of the chess board for a student and mentor. The primary purpose of this feature is for mentors to teach more efficiently.
Game Over
This message sends the final board state to both mentor and student, and allows the front-end to know that the game is over to display a game over message.