Web Sockets
q4aWebSockets
file: inside vote/a2REST.js is QUESTION: q4aWebSockets
url : does not apply, see next question
Modify the code in vote/q2REST.js
so that web socket connected clients see the current state of
all locks managed by q2REST.js. Do this by issuing
a SELECT query to the db to get all locks.
The result of the select is packaged and
broadcast to all connected clients.
q4bWebSockets
file: vote/static-content/q4bWebSockets.html
url : http://SERVER:PORT/q4bWebSockets.html
Complete the web sockets client code in q4bWebSockets.html
so that a user viewing this page will see the current
state of votes in the database managed by q2REST.js
keep it as simple as you can. No react etc. Just plain old JS/JQuery.
Example
The example below shows 142.1.200.151:8000/q4bWebSockets.html and
142.1.200.151:8000/index.html in two separate browser windows.
You should use your own server and port when implementing your solution.
Changes resulting from index.html immediately appear
in q4bWebSockets.html.
I now click 'yes' for th first question on
142.1.200.151:8000/index.html, we see the update there as well as immediately on
142.1.200.151:8000/q4bWebSockets.html