This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I have made a fairly simple turn-based multiplayer web game in an applet. My question is about the performance. I was noticing that there was a really long gap between a player taking his turn and the rest of the players seeing all the updates. It could be as long as 10 seconds for a single move/action.
The game runs on a dedicated server and all the players connect to the server as clients. As one player takes his turn, each move/action is sent to the server, and then from the server out to all the other clients. The server usually sends updates in the form of complete game-state objects, but also sends String messages. The client has a separate thread for listening for these updates. This is all done through a socket connection and persistent object input/output streams.
In my attempt to track down where the bottleneck is, I realized that if I run the applet from Eclipse (clicking "run as applet"), there is virtually no delay. So that means the client applets are sending out updates and the server is receiving them and then sending out it's updates perfectly. The bottleneck has to be in the applet's receiving/processing those updates.
I had two Chrome-applets and two Eclipse applets open on the same game. I would make a move on any of them and the two Eclipse applets would receive the server update instantly and the Chrome-applets would take as much as 10 seconds to get a single update.
Is there something import about different about how the applet runs in the browser vs in Eclipse? I know Eclipse is running the applet from local files, but doesn't a web-applet download all the appropriate files when it starts up? Thanks for your help. Let me know if posting some of my code would help.