程序代写代做代考 AWS Java javascript jquery 2017S v1.0 (3/30/2017) Page 1 of 3

2017S v1.0 (3/30/2017) Page 1 of 3

CS261 Semester Project

Assignment 4: Real-Time State Replication

This assignment extends assignment 2 (not 3, yet) with some new requirements. Refer to the
assignment 2 document for the explanation of concepts like API arguments and authentication.
All of the existing API features of your assignment 2 and 3 apps need to continue to function.

Integrate Game Prototype

Clone the repo at https://github.com/stebee/CS261Assignment2 to fetch a basic networked
game implementation. Integrate this with your existing app. This will mostly consist of bringing in
the routes/gameserver.js file, the /simulation and /views folders, and making some changes to
app.js–but do a diff to see all the differences.

You’ll need to update your load balancer to route all the game traffic to a single app server
(since the simulation runs entirely in memory). These lines should work when added (not
replacing—your existing server block should remain the same) to the top of your Nginx
configuration:

map $http_upgrade $connection_upgrade {
default upgrade;
” close;
}

upstream gameserver {
server YOUR_IP_ADDRESS:7000;
}

server {
listen 9009;
listen [::]:9009;
try_files $uri $uri/ @game;

Location @game {
proxy_pass http://gameserver;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
}
}

Additionally, copy the contents of the /public folder from the repo into /var/www/html on your

load balancer. These are the static files needed by the game client. It is more efficient to serve

these from the load balancer directly than to serve them from your Node app.

https://github.com/stebee/CS261Assignment2

2017S v1.0 (3/30/2017) Page 2 of 3

Frame Interpolation

The existing client code simply remembers the most recent frame received from the server and
displays it on request. Update this in the nextFrame method in /public/scripts/core/network.js so
that it remembers multiple frames and interpolates between them, as discussed in class. Also,
you will need to discard old frames once the game has progressed beyond needing them; the
current app keeps them around forever, which will eventually make the client run out of memory.

Integrate Authentication

The game client uses a simple but secure protocol to demonstrate knowledge of the token
shared secret associated with a session. Update verifyToken in /utils/auth.js to fetch session
information from your session system.

Create Login System

The app page that hosts the game client currently passes the session and token information in
to the game client. Replace this system with Javascript code in the game client that takes in a
username and password and posts them to the login method of your web API using jQuery’s
web request methods. jQuery is a standard client-side library in nearly-universal use to fix
deficiencies in the standard Javascript API browsers use. You can read more about using it for
web queries at http://www.tutorialrepublic.com/jquery-tutorial/jquery-ajax-get-and-post-
requests.php.

Expose Ping Time

The server currently tracks ping time. Expose this information to the client by creating a new
message type (give it a four-letter code like “STAT”) that contains this (and any other
information you find useful for debugging). Send a STAT message once a second in amongst
the other traffic. The client should just dump these messages to console.log.

Improve Serialization

The frame serialization code currently uses plain JSON, which is nearly the worst possible
format. Create something better. The more compact you make it the more points you will score.
The serializer is found in /simulation/replication.js, the client-side deserializer in
/public/scripts/core/frame.js.

Asteroids

Have the server generate some asteroids in random positions moving slowly on random vectors
with random rotations. You’ll need to update the client code to render these, but the sprites for
them already exist.

Submission and Grading
As with the previous assignments, deploy your code to your AWS servers and post a message
in the assignment dropbox on Moodle when you’re ready to be graded. This assignment is due
the morning Monday, April 10th. Because we are so close to the end of the semester, there will

http://www.tutorialrepublic.com/jquery-tutorial/jquery-ajax-get-and-post-requests.php
http://www.tutorialrepublic.com/jquery-tutorial/jquery-ajax-get-and-post-requests.php

2017S v1.0 (3/30/2017) Page 3 of 3

be no extensions granted for this assignment. Late delivery will count as a resubmission,
incurring a -10 penalty.

Your assignment will be graded by testing the features of your live server. Each of the six items
listed above is worth 20 points, with the overall score capped at 100—in other words, you can
skip one of those listed requirements entirely and still get a good grade.

Leave a Reply

Your email address will not be published. Required fields are marked *