chanpham97 / tici-taca-toey-robots

1 stars 0 forks source link

Support for communicating with server #1

Open chanpham97 opened 3 years ago

chanpham97 commented 3 years ago

Set up messages and connections to enable the following message flow:

  1. dispatch to self CONNECTED_TO_SERVER message
    • when socket opens
    • state.connected
    • Q: can you send REGISTER_ROBOT message right away? or does that happen after REGISTER_PLAYER
  2. server registers robot and sends REGISTER_PLAYER message
    • receive playerId
    • TODO: expand for handling of multiple robots? robot client to set up distinct connections per robot and maintain the different players
  3. robot client send UPDATE_ROBOT_INFO message to server
    • name
    • TODO: add difficulty level, number of games robot can play
  4. server receives robot game request and sends START_GAME to robot
    • specifies player/robotId
    • specifies game name, board size, winning length, etc
    • specifies person played against
    • specifies turn (start with client)
  5. robot receives MAKE_MOVE
    • TODO: send move to specified robot id
    • robot registers move and responds with its move ..
  6. robot receives GAME_COMPLETE
    • send message to server?
    • TODO: free up for more games
subramanian-elavathur commented 3 years ago

Following is what happens as soon as the server receives a websocket connection:

This was introduced to ensure that the server registers a player even if the client forgets to send the REGISTER_PLAYER message. So the users are allowed to click the start game button directly.

I am thinking that maybe we allow players to upgrade their type to a robot. With an UPGRADE_TO_ROBOT message.

Q: can you send REGISTER_ROBOT message right away? or does that happen after REGISTER_PLAYER

REGISTER_ROBOT / UPGRADE_TO_ROBOT - can be sent anytime after the socket is opened

Q. robot client send UPDATE_ROBOT_INFO message to server

I would recommend sending this information as part of the the UPGRADE_TO_ROBOT message

subramanian-elavathur commented 3 years ago

Alternatively we could change the current behavior to make the client always start off by sending a REGISTER_PLAYER message