Leviathan  0.8.0.0
Leviathan game engine
Leviathan::SentResponse Class Reference

Stores Responses that want confirmation that they have arrived. More...

#include <SentNetworkThing.h>

+ Inheritance diagram for Leviathan::SentResponse:

Public Member Functions

DLLEXPORT SentResponse (uint32_t sentinpacket, uint32_t messagenumber, RECEIVE_GUARANTEE guarantee, const std::shared_ptr< NetworkResponse > &response)
 
DLLEXPORT SentResponse (uint32_t sentinpacket, uint32_t messagenumber, const NetworkResponse &response)
 This is a variant that can't be resent. More...
 
DLLEXPORT std::string GetTypeStr () override
 
- Public Member Functions inherited from Leviathan::SentNetworkThing
DLLEXPORT SentNetworkThing (uint32_t packetid, uint32_t messagenumber, RECEIVE_GUARANTEE guarantee)
 
DLLEXPORT ~SentNetworkThing ()
 
bool IsFinalized ()
 Returns true once the packet has been received by the target or lost too many times. More...
 
DLLEXPORT void OnFinalized (bool succeeded)
 Called by Connection once this is done. More...
 
DLLEXPORT bool GetStatus ()
 Gets the status once IsFinalized returns true blocks otherwise. More...
 
DLLEXPORT void SetWaitStatus (bool status)
 Sets the status of the wait object notifying all waiters that this has succeeded or failed. More...
 
DLLEXPORT void SetAsTimed ()
 Sets this packet as a timed packet. More...
 
DLLEXPORT void ResetStartTime ()
 Resets the start time. More...
 
DLLEXPORT void SetCallback (std::shared_ptr< CallbackType > func=nullptr)
 Binds a callback function that is called either when the packet is successfully sent or it times out. More...
 
DLLEXPORT void SetCallbackFunc (CallbackType func)
 

Public Attributes

std::shared_ptr< NetworkResponseSentResponseData
 
int StoredType
 Stored for GetTypeStr with non-resendable responses. More...
 
- Public Attributes inherited from Leviathan::SentNetworkThing
uint32_t PacketNumber
 Contained in Local packet id. More...
 
const uint32_t MessageNumber
 
RECEIVE_GUARANTEE Resend = RECEIVE_GUARANTEE::None
 If not RECEIVE_GUARANTEE::None this packet will be resent if considered lost. More...
 
uint8_t AttemptNumber = 1
 
std::shared_ptr< std::function< void(bool, SentNetworkThing &)> > Callback
 
std::atomic< int64_t > ConfirmReceiveTime {0}
 The time when this packed got marked as received. More...
 
int64_t RequestStartTime {0}
 Time this was started. Used to time out this packet and calculate round trip time. More...
 
std::atomic< DONE_STATUSIsDone {DONE_STATUS::WAITING}
 Set to true once this object is no longer used. More...
 

Additional Inherited Members

- Public Types inherited from Leviathan::SentNetworkThing
enum  DONE_STATUS { DONE_STATUS::WAITING, DONE_STATUS::DONE, DONE_STATUS::FAILED }
 
using CallbackType = std::function< void(bool, SentNetworkThing &)>
 

Detailed Description

Stores Responses that want confirmation that they have arrived.

Definition at line 123 of file SentNetworkThing.h.

Constructor & Destructor Documentation

◆ SentResponse() [1/2]

DLLEXPORT SentResponse::SentResponse ( uint32_t  sentinpacket,
uint32_t  messagenumber,
RECEIVE_GUARANTEE  guarantee,
const std::shared_ptr< NetworkResponse > &  response 
)

Definition at line 96 of file SentNetworkThing.cpp.

97  :
98  SentNetworkThing(sentinpacket, messagenumber, guarantee),
99  SentResponseData(response), StoredType(static_cast<int>(response->GetType()))
100 {}
std::shared_ptr< NetworkResponse > SentResponseData
DLLEXPORT SentNetworkThing(uint32_t packetid, uint32_t messagenumber, RECEIVE_GUARANTEE guarantee)
int StoredType
Stored for GetTypeStr with non-resendable responses.

◆ SentResponse() [2/2]

DLLEXPORT SentResponse::SentResponse ( uint32_t  sentinpacket,
uint32_t  messagenumber,
const NetworkResponse response 
)

This is a variant that can't be resent.

Definition at line 102 of file SentNetworkThing.cpp.

103  :
104  SentNetworkThing(sentinpacket, messagenumber, RECEIVE_GUARANTEE::None),
105  StoredType(static_cast<int>(response.GetType()))
106 {}
Packet is sent once and if lost won&#39;t be resent.
DLLEXPORT SentNetworkThing(uint32_t packetid, uint32_t messagenumber, RECEIVE_GUARANTEE guarantee)
int StoredType
Stored for GetTypeStr with non-resendable responses.
NETWORK_RESPONSE_TYPE GetType() const

Member Function Documentation

◆ GetTypeStr()

DLLEXPORT std::string SentResponse::GetTypeStr ( )
overridevirtual

Implements Leviathan::SentNetworkThing.

Definition at line 108 of file SentNetworkThing.cpp.

109 {
110  // A bit hacky way to call the member function
111  return ResponseNone(static_cast<NETWORK_RESPONSE_TYPE>(StoredType), 0).GetTypeStr();
112 }
int StoredType
Stored for GetTypeStr with non-resendable responses.
DLLEXPORT std::string GetTypeStr() const
Empty keep alive response.

Member Data Documentation

◆ SentResponseData

std::shared_ptr<NetworkResponse> Leviathan::SentResponse::SentResponseData

Definition at line 134 of file SentNetworkThing.h.

◆ StoredType

int Leviathan::SentResponse::StoredType

Stored for GetTypeStr with non-resendable responses.

Definition at line 137 of file SentNetworkThing.h.


The documentation for this class was generated from the following files: