pollei / TicTacToe-java

TicTacToe game for SFCC CS141
GNU General Public License v3.0
0 stars 0 forks source link

WebGame can delete a game #8

Closed pollei closed 2 years ago

pollei commented 2 years ago

ConcurrentHashMap<String, GameWrap> gameMap needs way for finished or quit games to be removed . Add a POST fetch action=shutdown and a DELETE fetch that signal that gameid string and associated GameWrap should be removed. ttt.hml should send this when game is won or reset button is clicked. Also window.addEventListener('beforeunload', ...); After removed from HashMap then the GameWrap object should be eligible to be GCed; review to make sure that there aren't lingering references that could make the object a zombie. action=shutdown should be preferred so that if PvP mode is added both players can shutdown and gameid only gets removed when both agree. This follows https://github.com/pollei/TicTacToe-java/issues/7

Also there should be a way for games to be removed if idle too long. Such as if network connection is lost. This should be a separate issue once that basic scenarios are covered.

pollei commented 2 years ago

https://github.com/pollei/TicTacToe-java/commit/8a5e5cf0466fe141675724393ad0653ee034b63d addresses most of this. Need to test addEventListener('beforeunload', ...); aspect Added code that handles session timeout removing gameids as well. ttt.html only sends action=shutdown-gamme and noth both shutdown and report-move when ending conditions are detected. sending both at same time resulted in minor races

pollei commented 2 years ago

https://github.com/pollei/TicTacToe-java/commit/951164cebd430df79c5e7869c5d0f9f73f58765f added session keep-alive testing seems great so closing issue