Skip to content
TheThing edited this page Mar 9, 2011 · 1 revision

Network Library Introduction

Network Library provides an easy to use methods to add TCP/IP features into existing applications/games and is flexible to be used into future projects. With native object handling and powerfull serialiser you don't have to worry about parsing the data yourself or worry about the format of the packet. Network Library has extending error support as well as easy to understand code.

The Network Library uses plugins that takes care of actually making the connection and/or hosting a connection. Network Library provides the front-end while the plugin does the back-end. Currently only 2 plugins exist for Network Library. One of the plugin is a C# developed TCP/IP plugin that utilises sockets for it's connection while the other uses a python script to initiate a TCP/IP connection.

If you want to use UDP instead of TCP you can grab one of the plugin and make the necessary changes. Network Library is that flexible.

Features

The Network Library has many handy features but I will be listing the most important ones here.

  • Event registering

You can register methods in your code in an event like form. When receiving packets that fit the description, the event is run automatically with the contents of the packet as a parameter. Executing events is also easy. All you have to do is run SendEvent in the Network Library and the object you would like to send with it.

  • Object registering

One of the main features in the Network Library is the ability to register objects into the library. When this is done, all handling on that object is changed. If you register an object into the Library, the serialiser works faster, all references work and much more.

Lets say you have a board of 10 x 10 which is one object called GameBoard and each slot is an object of itself that I am gonna called GameTile. Then in order to register it into the library you just have to call Register and feed it the GameBoard. Register can register objects recursively and if done, will also register each GameTile inside the GameBoard. When this is done and we move unit from tile 03 to tile 13, we can choose to send the event over. Instead of the serialiser serialising both objects like normal serialisers would do, only the ID of the object is sent over. When the host sends a packet containing Tile_ID_03 to Tile_ID_13 the client decodes those ID to it's referenced objects.

With this you can actually do a reference check from the tile you received in the packet with the one you have in gameboard in your memory. For more information, read the Advanced Section - Registering objects.

  • Binding

Another great feature in the Network Library is the ability to bind objects directly into the Network Library. If done, then instead of you manually sending events for each change you do, Network Library does it by itself. This minimises the code you have to do and allows you to focus on the game or application instead of the network code.

In order for the binding to work, it has to implement IPropertyChanged and been Registered into the library. For more information, head over the the main article in the Advanced Section - Binding Objects