Phase 3: Multiplayer
Typing is more fun with friends! You'll now implement multiplayer functionality, so that when you run gui.py
on your computer, it connects to the course server at cats.cs61a.org and looks for someone else to race against.
To race against a friend, 5 different programs will be running:
- Your GUI, which is a program that handles all the text coloring and display in your web browser.
- Your
gui.py
, which is a web server that communicates with your GUI using the code you wrote incats.py
. - Your opponent's
gui.py
. - Your opponent's GUI.
- The CS 61A multiplayer server, which matches players together and passes messages around. It is not running on your machine.
When you type, your GUI sends what you have typed to your gui.py
server, which computes how much progress you have made and returns a progress update. It also sends a progress update to the multiplayer server, so that your opponent's GUI can display it.
Meanwhile, your GUI display is always trying to keep current by asking for progress updates from gui.py
, which in turn requests that info from the multiplayer server.
Each player has an id
number that is used by the server to track typing progress.
We recommand you to finish phase 3 in 3 days. ~50 lines code is needed.