
Show HN: Decentralized networking library for (not only) games - inetic
https://github.com/inetic/club
======
inetic
When we started working on our game, we knew we wanted it to feature
multiplayer. We did not know whether we'd earn money and hearing how much it
normally costs to run dedicated servers we wanted to avoid that cost, so we
decided to go the decentralized way and created Club library.

One of the features of a dedicated server is that you have a central authority
that makes decisions about who is in the game/lobby and who is not. In Club,
these decisions are done through a decentralized membership algorithm in such
a way that everyone receives membership changes in the same order.

Other that membership decisions, Club also offers an algorithm for totally
ordering messages. That is, if one node sends a message A and another node
sends a message B independently, it holds that if some node receives A before
B, then every other node that receives both messages will receive them in the
same order.

It should be noted though that such ordering is slow, because it requires an
acknowledgement from every other node in the network, but if performance is an
issue, this algorithm can be used for leader election, and after that the
leader may serve as a central authority for further and faster ordering of
messages.

Other feature that a dedicated server solves trivially is message routing.
Typically, users/nodes that are connected to the internet are behind some kind
of router, these sometimes go out of their way prevent two nodes from
establishing a direct connection between them. A dedicated server on the other
hand normally isn't behind a router or is set up in such a way that any node
can connect to it, thus any node that wants to communicate with any other node
may do so through the server. In Club - again - there is no central server,
but the library apart from maintaining who is in the network, also stores the
information about who is connected to whom, so for any two nodes that are in
the network, Club knows how to efficiently route messages between them.

Now there are also some other features that I did not mention, but there are
also many TODO items I've got.

Such as:

* Automatic establishment of full network where everyone tries to connect to everyone to reduce number of message hops and the risk of network partition (I had this already, but commented out the code while refactoring). * Symmetric NAT traversal (similarly, I had this, was commented out during refactor ). * Better congestion control. * Node to node routing (Currently only broadcast. Extending it should be trivial) * Encryption ...

Now, the questions that motivated this post: How big of a utilization do you
guys think there is for such library? Is it something that was already
implemented by other libraries? I checked RakNet and few others but AFAIK they
concentrate on the 'centralized server' approach, but maybe someone can
correct me? I would love to continue working on it, but the lack of seeing or
hearing of a similar approach used somewhere else makes me worry I'm being
naive so you guys may give me a cold shower :)

The library is written in C++11, it currently only depends on Boost (Mostly
Asio) and is distributed under the Apache 2 license (though I'm thinking of
relaxing it further to MIT).

(I cross posted this from
[r/gamedev]([https://www.reddit.com/r/gamedev/comments/4pg8kf/is_there_a_...](https://www.reddit.com/r/gamedev/comments/4pg8kf/is_there_a_demand_for_a_decentralized_networking/)),
I'm not too much of a writer, sorry about that)

