Tutorial: Showdown App
📄️ 1. Overview
Showdown is a simple, real-time voting App where members choose between two competing options — like Cats vs. Dogs — and see live updates as others vote. It's a good project for learning the core networking code in a Root App. To keep things manageable, the choices will be hardcoded and there won't be any database/persistence.
📄️ 2. Setup
You can develop for the Root Platform on Windows or macOS. You'll need to do a few Root setup tasks before starting to write code. Skip any steps that you've completed previously.
📄️ 3. Generate starter code
Root supplies a command-line utility named create-root that generates starter code. Here, you'll create your code, build it, and test that it works with your community.
📄️ 4. Display initial state
You'll store the number of votes for each option on your server. The number of votes for each will start at zero and go up as clients vote. Each time a new client starts up, that client will call over to the server to get the current vote counts. There won't be any persistence here; the counts will be held in memory on the server and will reset to zero every time you restart your server.
📄️ 5. Add voting
In this section, you'll add voting support. The UI will have two buttons. When a member clicks one of the buttons, you'll send a message to your server to record the vote. The server will return the new vote counts which you'll use to update your UI. There are three components to code: networking, server, and client.
📄️ 6. Broadcast votes
In this section, you'll notify all other clients whenever one client adds a vote. This will ensure all clients stay in sync with the data on your server.