Irrelon / ige

The Isogenic Game Engine
525 stars 140 forks source link

Proper way to add networking capabilities #281

Closed supinfo-dev closed 11 years ago

supinfo-dev commented 11 years ago

I am wondering what is the correct way to handle the addition of the network capabilities to my app.

In the documentation (http://www.isogenicengine.com/documentation/isogenic-game-engine/versions/1-1-0/manual/networking-multiplayer/basic-network-messaging/), it says:

ige.addComponent(IgeSocketIoComponent);

but in many of the examples (i.e the 24.* ones), I see:

ige.addComponent(IgeNetIoComponent);

What is the difference between the two ?

Irrelon commented 11 years ago

IgeSocketIoComponent uses the socket.io networking library whereas the IgeNetIoComponent uses the net.io networking library.

You can google both to read about them. Socket.io is a third-party networking library that has many features and benefits like support for websockets with automatic fallback on browsers that don't support websockets, handling of large amounts of data in a single send command etc.

Net.io was developed by me and is a very lightweight (and high performance) library that was designed specifically for games. It ONLY has websocket support, does not provide breaking up large data into smaller packets (you should not use it for transferring large amounts of map data all at once for instance as it will not work), but it is significantly faster than socket.io and uses much less bandwidth per packet of data. Socket.io pads all data it sends with lots of extra information which is great for use in something like a chat system but not great for realtime games where every byte counts.

The lowdown is this... if you want to run on all browsers regardless of if they support websockets (all the older shitty ones), need to send large amounts of data without breaking it up into smaller parts then then use socket.io.

If you are building a realtime multiplayer game that needs every last byte to be optimised and accounted for, doesn't intend to send lots of data in a single packet and you don't mind ignoring browsers without websocket support then use Net.io.

I've made both components to be library agnostic so you can write code for one then switch to the other and your code will still work.

supinfo-dev commented 11 years ago

that was very clear yet precise, thanks!