HTTP, Web Interfaces
- Learn about the HTTP protocol.
Do web searches and read about it until you feel that you understand it.
- Download and build this program.
It is a very simple web server that I wrote in Java.
Study the code until you understand it.
If you have trouble following any of it, please ask questions.
- Write a multi-player game.
Two people should be able to point their web browsers at your server.
The first one to connect should control Mario.
The second one to connect should control a goomba.
Whenever either one of them moves, both browser windows should see the character move.
I am not concerned if there is a bit of lag.
I don't really care what is the objective of your game.
Just make sure that if you move Mario in one browser tab, it moves the same way on the other one, and if the other player moves the goomba, it moves the same way on the first browser tab.
- Add a chat window to your game.
Here is some HTML code for a chat window,
and here are some tutorials that talk about implementing something like this:
- Submit an archive file containing everything needed to make this work.
Click on the "Project submission" link on the main class page to submit your archive file.
If you have any difficulties with the submission server, please e-mail your submission directly to the grader.
FAQ:
- Q: I'm getting about a second of lag (a.k.a. latency). Is that acceptable?
A: Yes, that is fine.
Q: How would I fix it, anyways?
A: Do you see how this web server closes the socket after each message?
That wastes a lot of time establishing new connections each time.
HTTP supports keeping the socket open, so you could fix that.
In high-quality on-line games, the server measures the latency (a.k.a. ping time) and projects how much change has probably occurred,
so the user often cannot tell when there is lag.
Also, it is common to use UDP instead of TCP, because UDP has much less overhead.
- Q: I'm getting an exception saying the file "C:\Users\YourName\Desktop\School\Paradigms\Assignment8\somefile.png" is not found.
A: The grader does not have a folder named "C:\Users\YourName\Desktop\School\Paradigms\Assignment8" on his machine,
so don't put that string (or any string like it) anywhere in your program.
Do not hard-code any filenames in your program. It should work with whatever directory structure the grader has on his machine.
Also, never use back-slashes ("\"). They only work on Windows. Always use forward-slashes ("/").
- Q: How do I determine which folder my program beings running in?
A: Open your favorite search engine. Type "java current directory". Press Enter.
|