December 2015
Beginner to intermediate
522 pages
11h 21m
English
With all of the things happening on the client side, be it rendering sprites or playing sounds or processing user input, it only makes sense to have all of the networking code localized inside a single class. This will allow us to communicate with the server quickly and easily. Let's begin designing that class, by first taking a look at some necessary definitions inside the Client.h header:
#define CONNECT_TIMEOUT 5000 // Milliseconds. class Client; using PacketHandler = std::function< void(const PacketID&, sf::Packet&, Client*)>;
The first definition is the amount of milliseconds that it takes for a client to realize that it's no longer connected to a server. This value can obviously be tweaked at any time. Following ...
Read now
Unlock full access