Spring 2018
Programming Assignment 1: Asterix and the Olympic Games (Winter Olympics Edition)
Due: Friday March 2, 2018, 23:59 hours
Assume that there are N tablets, each of which is a client, that needs to be periodically updated with sports scores. (N should be configurable in your system).
First design a client-pull architecture where each client tablet refreshes the medal tally by periodically pulling the latest data from Obelix's stone server. Additionally a client tablet can also request the current score for an ongoing sports event and receive a response from the server.
Cacofonix, the village bard, is responsible for providing Obelix's server live updates from the olympic stadium, which he does by singing the scores and thereby sending updated scores to the server. Since Gauls are restful by nature, they have chosen to use the RESTful API for client-sever communications. The RESTful interface provides a simple method for RPC-like communication over HTTP.
SERVER_IP:80/getMedalTally/teamNameThis should return a json object that contains the number of gold, silver and bronze leafs earned by the specified teamName. Your system should track medal tallies for at least two teams, namely Gual and Rome.
SERVER_IP:80/incrementMedalTally/teamName/medalType/auth_idThis increments the medal tally for the specified team, and medalType can be bronze, silver, or gold and the appropriate medal count for that team is incremented. The auth_id variable should be an id unique to Cacofonix used to authorize the action. This should return a success message on successful increment by Cacofonix and a failure message if anyone other than Cacofonix tries to increment the tally.
SERVER_IP:80/getScore/eventTypeThis should return a json object with the latest score for each team for the specified eventType. Pick at least three winter Olympics events such as stone Curling and stone skating and provide scores for these events.
SERVER_IP:80/setScore/eventType/rome_score/gaul_score/auth_idThis updates the current score for the specified event. The auth_id variable should be an id unique to Cacofonix used to authorize the action. The variables gaul_score and rome_score should be the new score values for each team. This should return a success message on successful update by Cacofonix and a failure message if anyone other than Cacofonix tries to update the score.
SERVER_IP:80/registerClient/clientID/eventTypeThis registers a client tablet to receive push updates for the specified eventType.
Client_IP:80/pushUpdate/variable1/variable2/variable3/...etcThis should be called for all registerd clients and pushes an update of the current state to all registered clients.
serverIP:80/getMedalTally/teamName
{ "medals": { "bronze": 0, "gold": 2, "silver": 5 } }
We do not expect elaborate use of github or testing frameworks - rather we want you to become familiar with these tools and start using them for your lab work (and other programs you write).