Summary
GameNet is a client / server RPC system using newest C++11 templates to make the life easier for you. When registering RPCs, function parameters are auto-detected from the function pointer. When calling RPCs, variardic templates allow extracting data from arbitrary parameter counts.
Features
* Supports GLM datatypes for use in 3D Games
* Supported data types : (u)char,(u)short,(u)int,float,double,vector,map, GLM vec,mat and quat
* Support for data type nesting like map [ string , vector ]
* RPC Data-type mismatch or wrong number of parameters are stated as error to ease debugging
* Numbers are automatically sent as the smallest possible datatype (byte, short , .. )
* Reliable and unreliable calls possible
* Function pointers of remote functions are not required
* Based on ENet
* Compression (Enet standard)
* Hack-safe - illegal packets are discarded
* Tested on Cygwin and Windows, should compile in Linux too
* Byte order preserved (hton/ntoh)
Limitations
* RPCs cannot be class member functions
* No encryption
* Only void functions supported. Non-void functions were tested but complicated everything.
* Client to Client connections are not supported
Example Game Features
* Lobby
* Multiple Games
* Handle spawning/removing of game objects
* Simple Shooting functionality
* Intentionally in text mode to make it as simple as possible for you to adapt the code
Example Usage
Server Side:
NetServer server;
void login(uint clientid, string name, string password)
{
// clientid is attached as 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();
}
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();
}
Screenshots of the included example game: