Redis is used for both it's pub/sub capability and quick key/value storing capability.
The pub/sub capability is used by socket.io as an adapter. This is entirely managed by socket.io-redis. Web sockets are tied to the server that it has initiated the TCP handshake with, so naturally aren't scalable. socket.io-redis and Redis solves this problem for us by leveraging the pub/sub capability within Redis.
Redis is also used for it's key/value, to store metadata about currently running rooms, for example: who is in the room, their name, their score, their role in the game etc.
sudo apt install redis-server
By default Redis is only accessible from localhost, which is what we want.
Check if Redis is running:
sudo systemctl status redis-server
Ping Redis:
redis-cli -h localhost ping
Start client server on port 8080.
cd client && npm run serve
Start Express server on port 3000.
cd server && node server.js
In development the client will point socket connections at localhost:3000.
Install stuff:
npm install
Compiles and hot-reloads for development:
npm run serve
Compiles and minifies for production:
npm run build
Run your unit tests:
npm run test:unit
Lints and fixes files:
npm run lint
Run locally
npm run serve
Run server code unit tests
npm test
./build.sh
Compiles Vue.js app and moves to ./server/public
.
Commit these files to master
at this point.
./deploy.sh
Pushes latest master to heroku.
Selenium is used to run automated tests in the browser, to make sure nothing is broken. Cypress would have been used but it doesn't support mulitple tabs.
sudo apt install geckodriver-firefox
pip3 install selenium
Run geckodriver
geckodriver
Once geckodriver is running locally, you can run any of the tests in /simulations
.
python3 test.py