26 #include "nrg_packet.h"
33 enum StateResult : uint32_t {
34 STATE_CONTINUE = 0x00,
35 STATE_EXIT_BIT = 0x10,
36 STATE_FAILURE = STATE_EXIT_BIT,
37 STATE_CHANGE = STATE_EXIT_BIT | 0x01
41 enum StateFlags : uint32_t {
43 SFLAG_TIMED_OUT = 0x01
47 enum HS_Reponses : int8_t {
48 HS_WRONG_LIB_VERSION = -1,
50 HS_WRONG_GAME_VERSION = -3,
63 virtual bool ready() = 0;
99 void reset(
bool ready_to_send);
bool sentPackets()
Returns true if one or more packets have been sent through this StateConnectionOutImpl since the last...
Implementation of StateConnectionOut.
Definition: nrg_state.h:94
virtual bool needsUpdate() const =0
Called to see if the State would like to be updated.
virtual Status sendPacket(Packet &p, PacketFlags f=PKTFLAG_NONE)=0
Try to send a packet, returns a error Status if it couldn't because of the rate-limit.
Status sendPacket(Packet &p, PacketFlags f=PKTFLAG_NONE)
Try to send a packet, returns a error Status if it couldn't because of the rate-limit.
Interface for wrapping ConnectionOut with rate-limiting functionality.
Definition: nrg_state.h:61
virtual StateResult update(StateConnectionOut &out, StateFlags f=SFLAG_NONE)=0
Called to update the state (or on a timeout) allowing it to optionally send some Packets using out...
Class for storing data to be sent / received across the network.
Definition: nrg_packet.h:58
virtual Status resendLastPacket()=0
Try to resend the last packet send, returns an error status if it couldn't because of the rate-limit...
Represents a connected client on the server.
Definition: nrg_player.h:34
virtual bool ready()=0
Returns true if more Packets can be sent right now with sendPacket.
virtual size_t getTimeoutSeconds() const
Returns a time that the state can go without needsUpdate() returning true, after which update() will ...
Definition: nrg_state.h:84
StateConnectionOutImpl(ConnectionOut &out)
Default constructor.
Outgoing connection class.
Definition: nrg_connection.h:99
virtual ~State()
Default destructor.
Definition: nrg_state.h:90
The main server-side class of the library.
Definition: nrg_server.h:44
virtual bool init(Client *c, Server *s, Player *p)=0
Called to (re)initialise this State instance, for Client-side c won't be null, but s and p will...
Abstract class that represents a protocol followed by the Server and Client.
Definition: nrg_state.h:73
Contains functionality that adds a connection abstraction over UDP.
Class to wrap system and internal errors.
Definition: nrg_status.h:34
Status resendLastPacket()
Try to resend the last packet send, returns an error status if it couldn't because of the rate-limit...
bool ready()
Returns true if more Packets can be sent right now with sendPacket.
The main client-side nrg class.
Definition: nrg_client.h:42
virtual bool onRecvPacket(Packet &p, PacketFlags f)=0
Called when a Packet is recieved and this is the active State, f shows if the packet was out-of-order...
void reset(bool ready_to_send)
Marks the StateConnectionOutImpl so that ready_to_send decides if more packets can be sent or not...
Common defines and includes used by all the other nrg header files.