markcornwell / spacewar

Javascript implementation of 1962 game Spacewar! originally developed for the PDP-1
MIT License
0 stars 0 forks source link

Game list in the lobby display is not updating from matchmaker. #46

Open markcornwell opened 4 years ago

markcornwell commented 4 years ago

To recreate

cd ~/welcome-to-spacewar
npm run start

in a new window

 cd ~/spacewar
 npm run matchmaker

In browser go to http://localhost:3000 Network Play

No games are displayed.

In a third window, try

cd ~/spacewar
bin/mm new
bin/mm new

You should now see games displayed in the Network play screen.

markcornwell commented 4 years ago

I am coming to the conclusion that the whole schema for matchmaker is flawed. Why is it based on app instead of router? Why am I getting back a bunch of HTML in front of my json responses. Why do the good tutorials I look at base their restful interface on router and not on app? This code is a mashup from many sources and I don't have clear understanding how it works under the covers.

So may do something radical. I am going to pull apart the matchmaker so they are in separate packages.

markcornwell commented 4 years ago

Take a look at this tutorial which had a big influence on my thinking.

https://www.youtube.com/watch?v=fgTGADljAeg

It goes along with the code at https://www.youtube.com/redirect?q=https%3A%2F%2Fgithub.com%2FWebDevSimplified%2FYour-First-Node-REST-API&redir_token=OjO_Ba0nclwwQ5rAWmnUIk3-2B18MTU4MTM2ODE4M0AxNTgxMjgxNzgz&event=video_description&v=fgTGADljAeg

Which I think makes a good exemplar for restful interfaces using nodejs + express + mongodb A stack that is clean, modern, ascendant, and well supported.

markcornwell commented 4 years ago

The hitch is sessions. I used some voodoo for session creation that I do not fully understand. The router based paradigm is clearer to me, and if I understand correctly, I can put the session support inside what they call middleware. (They use the term a little differently -- with a much more specific meaning that I am used to -- but the term fits).

Taking it on faith that I can implement the session support I need in the router middleware -- either pulled from public sources -- or something I can craft myself.