49 Client(
const std::string& game_name, uint32_t game_version,
InputBase& input);
55 Client(
const std::string& game_name, uint32_t game_version);
70 template<
class M,
class F>
72 game_state.registerMessage(M(std::forward<F>(f)));
109 EventQueue& getEventQueue() {
return eventq; }
110 UDPSocket& getSock() {
return sock; }
111 const std::string& getGameName() {
return game_name; }
112 const uint32_t getGameVersion() {
return game_version; }
113 const int getPlayerID() {
return player_id; }
117 void setServerParams(
const Version& lib_v, uint32_t game_v, uint16_t pid);
126 NetAddress serv_addr;
128 StateConnectionOutImpl state_con;
130 StateManager state_manager;
131 ClientHandshakeState handshake;
132 ClientGameState game_state;
133 uint32_t rate_limit_interval_ms;
134 uint32_t previous_ms;
135 std::string game_name;
136 uint32_t game_version;
139 char dc_reason[NRG_MAX_ERRORMSG_LEN];
void addMessageHandler(F &&f)
Adds a function f, that will be called when the Client receives a Message of type M...
Definition: nrg_client.h:71
void setPacketRateLimit(uint32_t packets_per_sec)
Sets a limit on how many full Packets the Client will send per second.
Abstract base class for Message.
Definition: nrg_message.h:36
Functionality related to managing changing States.
Contains Message classes and functionality for two-way RPC between Server and Client.
const NetAddress * getConnectedAddress() const
Returns the NetAddress this Client is connected to, or nullptr if not connected.
Contains the default State classes used by the Client, ClientHandshakeState and ClientGameState.
const ClientStats & getStats() const
Returns a ClientStats reference, which contains statistics about this Client's connection.
Union to contain all the event types.
Definition: nrg_event.h:72
Contains the NetAddress class for wrapping POSIX sockaddr structures and resolving hostnames to IP ad...
Functionality to notify users of Client and Server occurances.
Abstract class to be inherited by users of the library which acts as a container of one or more Field...
Definition: nrg_entity.h:37
Client statistics interface.
Definition: nrg_util.h:66
void sendMessage(const MessageBase &m)
Queues the the user-defined Message m to be sent to the connected Server.
Library versioning stuff.
bool isConnected() const
Returns whether or not this Client is connected or not.
bool pollEvent(Event &e)
Places the next Event from the Client's EventQueue into e, returning true if this happened...
Classes to wrap POSIX sockets.
void stopRecordingReplay()
Stops recording received packets into a file called filename.
uint32_t getPacketRateLimit(void)
Gets a limit on how many full Packets the Client will send per second.
~Client()
Standard destructor.
void startRecordingReplay(const char *filename)
Starts recording received packets into a file called filename.
void setUserPointer(void *p)
Set a user-defined pointer to be associated with this Client instance.
Definition: nrg_client.h:103
bool update()
Sends and Recieves any queued Packets and updates the contained State classes, returns false on error...
The main client-side nrg class.
Definition: nrg_client.h:42
bool connect(const NetAddress &server_addr)
Sets the address of the Server to connect to, and calls Socket::connect on it.
Client(const std::string &game_name, uint32_t game_version, InputBase &input)
Standard Client constructor.
void registerEntity(Entity *e)
Registers a subclass of Entity with this Client, must be called once for each user-defined Entity bef...
Common defines and includes used by all the other nrg header files.
Class to wrap the various POSIX sockaddrs and resolve hostnames.
Definition: nrg_netaddress.h:32
void * getUserPointer() const
Get a user-defined pointer to be associated with this Client instance.
Definition: nrg_client.h:101