Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
165
rated 0 times [  168] [ 3]  / answers: 1 / hits: 59095  / 13 Years ago, thu, november 17, 2011, 12:00:00

I'm interested in building a small real-time multiplayer game, using HTML5/JavaScript for the client and probably Java for the server software.



I looked into WebSockets a bit, but it appears I had misconceptions on what WebSockets actually are. I had initially thought of WebSockets as just JavaScript's way of handling TCP sockets, just as they are used in Java and other languages, but it appears there is a whole handshaking process that must take place, and each transmission includes much HTTP overhead (and in that case, the benefits over Ajax do not seem as exciting as at a first glance)?



On a related topic, are there any better alternatives to WebSockets for this purpose (real-time multiplayer games in JavaScript)?


More From » websocket

 Answers
8

WebSockets are the best solution for realtime multiplayer games running in a web browser. As pointed out in the comments there is an initial handshake where the HTTP connection is upgraded but once the connection is established WebSockets offer the lowest latency connection mechanism for bi-directional communication between a server and a client.



I'd recommend you watch this: https://www.youtube.com/watch?v=_t28OPQlZK4&feature=youtu.be



Have a look at:





The only raw TCP solution would be to use a plugin which supports some kind of TCPClient object. I'd recommend you try out WebSockets.



You can find a number of options here. Just search for WebSockets within the page.



Also take a look at WebRTC. Depending on the purpose of your game and whether you need your server to manage game state, you could use this technology for peer-to-peer communication. You may still need a solution to handle putting players into groups - in that case WebSockets is the fastest/best solution.


[#89073] Tuesday, November 15, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eden

Total Points: 730
Total Questions: 117
Total Answers: 117

Location: Peru
Member since Fri, Oct 14, 2022
2 Years ago
;