Jump to content

HTML5 multiplayer ?


Biggerplay
 Share

Recommended Posts

I'm thinking of doing a html5 multiplayer game and I'm researching the options for that.

 

  1. Does anyone have any suggestions for the best way to go in regards to server API's etc? I'm aware of parse.com and pusher.com
  2. Are there any particular issues to be aware of when dealing with multiplayer games and JS?
  3. Regarding the front end, are any particular libraries better suited to multiplayer than others?

Thanks for any advice.

Link to comment
Share on other sites

Meteor looks gorgeous for games. I suggest you to give a try.

 

The famous Mozilla game called BrowserQuest uses node.js / websockets, and it's open-source.

 

Meteor looks great for building websites and games that don't depend on having low latency. But if your goal is to build a game where 10-20 or maybe even hundreds of players are all playing simultaneously, you're probably going to end up at another solution. So I recommend just straight up NodeJS and Websockets.

 

 

Here is a good read about some of the invisible issues caused by high latency that most games hide very well. http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/

 

Very good articles about general game network programming IMO:

http://www.gameproducer.net/2006/12/16/planning-is-essential-in-writing-multiplayer-network-code/

Link to comment
Share on other sites

Meteor looks great for building websites and games that don't depend on having low latency. But if your goal is to build a game where 10-20 or maybe even hundreds of players are all playing simultaneously, you're probably going to end up at another solution. So I recommend just straight up NodeJS and Websockets.

 

 

Here is a good read about some of the invisible issues caused by high latency that most games hide very well. http://gafferongames.com/networking-for-game-programmers/what-every-programmer-needs-to-know-about-game-networking/

 

Very good articles about general game network programming IMO:

http://www.gameproducer.net/2006/12/16/planning-is-essential-in-writing-multiplayer-network-code/

So that just applies to real time multiplayer, what about turn based? or even basing the game on rooms (lobbies) so you limit the number of people in a room, even though overall there might be many rooms being used.

Link to comment
Share on other sites

Being aware of latency and taking that into account in the design of your multiplayer component of a game is quite important. Since websockets work over TCP, poor quality of service results in bursts of information. You can have a relatively consistent stream of information for a while and periodically get spikes in latency followed by a flood of messages. This will mainly affect real-time multiplayer games.

 

While we were working on Score Rush Multiplayer (4-player bullet hell shooter) we spent a lot of time making sure that these spikes in latency affected the player's experience as little as possible.

We added a few bits of advice to the game development tips section of our documentation

 

If you're interested here is our real-time multiplayer API, which is a session based, client-to-client interface that uses websockets and quick relay server.

We also have a turn-based API in the works, which it sounds like something you would be more interested in.

 

 

Link to comment
Share on other sites

I would recomend to use the more popular "Client-Server" architecture, at least your first time. Either using native WebSockets or a Library which provides fallbacks eases the setup on your own server. In addition, if you like to use Node.js - you could share some Code for the calculations/predictions  ;)

 

You can find here an overview + example: http://www.wildbunny.co.uk/blog/2012/10/09/how-to-make-a-multi-player-game-part-1/

 

The Problem with the "Peer-To-Peer" approach is the data handling and usability right now. As the entire game will run on the client side, it's difficult to prevent abusage and cheating. As currently no stable browser supports DataChannels, it's also unlikely to be played by common websters.

 

If you are interested what holds up the future: I am working on a P2P Gaming Framework called PeerGaming for my graduation.

My research is almost done, so I should be able to start with the implementation soon  :)

Link to comment
Share on other sites

if you plan on doing a real-time multiplayer, take a look at how http://banditracer.eu/ does it.

 

Domas - the author - ported Vavle's network prediction & lag compensation and it workes quiet well (not for dozens of users but good enough for 4 racers).

 

edit: the Valve wiki has an excellent explanation of interpolation, etc <https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking>

Link to comment
Share on other sites

So that just applies to real time multiplayer, what about turn based? or even basing the game on rooms (lobbies) so you limit the number of people in a room, even though overall there might be many rooms being used.

 

Meteor is probably ok for turn based. But it's scope is limited. I would just learn and implement with node.js/socket.io so if you want to move onto something other than turnbased later, you already know how to use node.js and socket.io.

Link to comment
Share on other sites

@Quetzacotl your argument was maybe true some years ago :) V8engine and Nodejs with it's support to both native and JS extensions changed things.

and if we are speaking about network speed, JS, C# or C++ code has nothing to do with that, network latency will be allways the same if you use TCP (I'm not speaking about UDP here nor about some specific protocols witch add overhead to network requests :) )

Link to comment
Share on other sites

@Quetzacotl your argument was maybe true some years ago :) V8engine and Nodejs with it's support to both native and JS extensions changed things.

and if we are speaking about network speed, JS, C# or C++ code has nothing to do with that, network latency will be allways the same if you use TCP (I'm not speaking about UDP here nor about some specific protocols witch add overhead to network requests :) )

Obviosly I'm not talking about network speed and I don't know why you would think otherwise. Javascript wasn't designed to work as a server backend, there are many better alternatives for this purpose. node.js can be a way to go if you don't know other lanugages and you don't plan to scale app much, since node.js is hard to scale (I don't say it's impossible, it's just much harder).

 

 I have to quote this 

Node.js does help you to fail fast

Link to comment
Share on other sites

Javascript wasn't designed to work as a server backend,

 

Not true at all - besides the latest node effort, it was almost 20 years ago used for this purpose: https://en.wikipedia.org/wiki/Server-side_JavaScript#Server-side_JavaScript

 

The good part of using a Node.js backend for gaming, is the simplicity and community support. In case you want to do realtime communication, you can just leverage the complex part and use a WebSocket library via npm. Many people here could probably help you with the setup etc. Other environments are great as well - but as you will probably use JavaScript on the client side, so you get the chance to re-use some code or at least exercise your scripting skills  :)

Link to comment
Share on other sites

I think you misunderstood. I said js wasn't designed for backend, not that it wasn't used there. 

 It was originally implemented as part of web browsers so that client-side scripts may interact with the user, control the browser, communicate asynchronously and alter the document content that is displayed.

You know that javascript was designed in about 10 days? It says everything about it.

 

I tried node.js, as well I wrote my own TCP server with Python, I also wrote my own websocket library. RIght now I'm developing app using Twisted and it's much, much easier to maintain and develop, and still it's faster. It's not node.js fault, it's javascript fault. I know that ppl now are hyped about it for no real reason, except that you don't have to know any other language than js.

Link to comment
Share on other sites

 node.js can be a way to go if you don't know other lanugages and you don't plan to scale app much, since node.js is hard to scale (I don't say it's impossible, it's just much harder).

 

Define "harder to scale". I've found it quite easy to scale. When you talk about what the language was designed for, and the async model - those arguments are purely academic... but in the real world, companies like eBay, 37signals, Cloud9, Yahoo!, LinkedIn, Flickr, Microsoft , Twitter (on a small scale), Instagram (I think)... are all using nodejs on the server side. These are companies that really have to deal with massive scaling. By your own admission, you've only "tried" it. Show some real world examples of how/why nodejs is a poor choice for scaling.

 

 

Projects, applications, companies using nodejs

Link to comment
Share on other sites

  • 3 weeks later...

Well, I'm currently diving into WebRTC, I found this lengthy article on html5 rocks that sums it up pretty much: http://www.html5rocks.com/en/tutorials/webrtc/basics/

 

If I'm not mistaken, it has a component (RTCPeerConnection or rather DataChannel?) that should pretty much allow you to implement UDP-like connections, wich we all know is mandatory for real time multiplayer games.

 

It's not even listed on caniuse for some reason, but it seems to be widely supported by firefox and chrome now, althought with prefixes.

 

I haven't had the time to whip-up a demo, but if anyone's interested my job here'll be done.

Link to comment
Share on other sites

@ZippoLag:

 

Unfortunately it's quite the opposite: most browsers doesn't have it implemented yet - especially for accessing it directly. To send arbitary data/messages, you need create a DataChannel which can be created after a PeerConnection got established. So far DataChannel are only available using a Commandline Parameter in Chrome 26 (+ without in Canary). Other WebRTC features like MediaStreams via getUserMedia() or solely PeerConnections are also available in Firefox & Opera (~ probably the reason it's not listed at caniuse.com). 

 

As you also still need an additional signaling channel, it's more complex to handle these connections compared to WebSockets + the current implementation doesn't provide reliable candidates. If you are still interested in P2P via WebRTC I would recommend you to take a look at PeerJS or PeerGaming. Hopefully in a few months PC/DC will get better support  :)

Link to comment
Share on other sites

  • 2 weeks later...

It is and shows what will be possible - just that the demo shows an specific use case with an hard coded implementation for their needs  ;)

(as they used BananaBread, their emscripted port of Sauerbraten 2 compiled from native "C" code)

 

With Chrome M28 reliable DataChannel should be available as well and with the latest changes in Firefox Nightly - we hopefully can work towards a cross-browser solution for gaming. As no one likes to use an additional server setup, the bootstrapping process + P2P brookering should be included in the initialization. So let's see how to tackle that as well as persistent network-data for late join & reconnects  :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...