Home

Awesome

Game NET - A Simple RPC Network Library (C++11)

Write a simple server / client RPC system in just 10+20 lines of code.

Write a multiplayer game with client / server in 300+300 lines of code.

License : MIT

http://opensource.org/licenses/MIT

Summary

The library provides basic client / server network functionalities for games using RPCs. The major strength of the library is the template based RPC class. It allows to register and call RPCs effortless. It further includes a tutorial game server and game client (each around 300 lines of code ) for a very simple multiplayer shooting game as a proof of concept.

Network RPC Lib Features

Network RPC Lib Limitations

Example Game Features

Benchmark

A first simple test on localhost (Core i7 Notebook) gave:

1 Call / Network Update:

10 Calls grouped / Network Update

20 Calls grouped / Network Update

Note that this is not about the response time

Example Usage

Call Server Function:

Client Side:

NetClient client;

void set_pos(vec3 pos)
{
    // do something
    exit(0);
}

int main()
{
    rpc_register_remote(client.get_rpc(), login);
    rpc_register_local(client.get_rpc(), set_pos);
    client.connect("localhost", 12345);
    client.call("login", "myname", "pass");
    while(1) client.process();
    //client.disconnect();
}

Server Side:

NetServer server;

void login(uint clientid, string name, string password)
{
    // clientid is the first parameter for server functions
    server.call(clientid, "set_pos", vec3(1,2,3));    
}

int main()
{
    rpc_register_local(server.get_rpc(), login);
    rpc_register_remote(server.get_rpc(), set_pos);    
    server.start();
    core_sleep(10000) ; // wait client to do stuff
    server.stop();
}

Screenshot1 Screenshot2

RPC System, how its done: http://cpp.sh/9jc5

(C) by Sven Forstmann in 2015