By Will Garrison, Joshua Brown, Sankalp Patil, and Bradley Rule
Using fonts by Omnibus-Type
- By default, this program expects to be located in
/var/www/newsie. To run the program elsewhere, modifyWorkingDirectoryinnewsie.serviceor run without Systemd. - By default, this program will run on port 3000. To choose a different port,
modify the
PORTvariable inserver.js.
- Change variables
WSaddrandHTaddrat the top ofpublic/pregame.jsto point to your own domain or IP address. - Copy
newsie.serviceto/usr/lib/systemd/system/newsie.serviceor other directory scanned by Systemd. - Run
systemctl daemon-reloadto make Systemd discover the new service file. - Run
sudo systemctl enable newsieand thensudo systemctl start newsieto begin your newsie server.
To run without Systemd for testing or otherwise, simply run
node server.js.
Enjoy!
There are 5 states a game can be in at any time. A game is created once a user
has hit the Create Game button and entered a nickname. The game states are as
follows (With a screenshot attached in the dropdown):
GET
-
/subtitle-
Returns a random line from subtitles.txt
-
Status 200
-
-
*- Handled by Express.js
POST
-
?game&name-
Joins
gameif exists, as usernameif available. -
Status 201 if successful, 400 if not.
-
-
?game-
Checks to see if
gameexists. -
Status 200 if found, 404 if not found.
-
-
?name-
Creates new game as user
name. -
Status 201 including the newly created game code.
-
FROM CLIENT
- Game Creation or Join Game
GameCode + NickName //(ex. "ABC123John Doe")Server: Game manager searches the GameCode's user map for the user NickName, and replaces the index with the websocket id. (ex, Users[WebSocket] = Users["John Doe"])
- Game Owner Starts Game
"Start Game"- Submit an Image
image: String //Image Base64 Data URL- Submit Votes
votes: [Int] //Array of original indexes rearranged according to vote order- Game Owner Next Round
"Next Round"FROM SERVER
- Anytime: Error Message
id: "error"
state: String
level: Int //ErrorLevel, as described in Error Handling below
message: String- Lobby: Update users on join
id: "lobby"
usernames: [String]
gameowner: String- Submission: Send out prompt
id: "round"
headline: String
roundStart: Int //Timestamp
roundEnd: Int //Timestamp
roundNumber: Int- Voting: Send out images to vote on
id: "images"
images: [{
user: User,
image: String, //Image Base64 Data URL
votes: Int
}]
voteStart: Int //Timestamp
voteEnd: Int //Timestamp
roundNumber: Int- Round End: Send out round results
id: "results"
winner: String
winningImage: String //Image Base64 Data URL
currentPoints: Int //Clients total points
pointsEarned: Int //Points client earned this round
roundNumber: Int- Game End: Send out winner
id: "end"
winner: String //Nickname of winnerServer Error Levels:
Game Crashed, Go back to start and do not collect $200Error processing input. Resubmit entry/votes.Unknown websocket. Resend "GameCode + Nickname" message





