Leviathan  0.8.0.0
Leviathan game engine
Leviathan::SentRequest Class Reference

Stores Requests while they are waiting for a response. More...

#include <SentNetworkThing.h>

+ Inheritance diagram for Leviathan::SentRequest:

Public Member Functions

DLLEXPORT SentRequest (uint32_t sentinpacket, uint32_t messagenumber, RECEIVE_GUARANTEE guarantee, const std::shared_ptr< NetworkRequest > &request)
 
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< NetworkResponseGotResponse
 
std::shared_ptr< NetworkRequestSentRequestData
 
- 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 Requests while they are waiting for a response.

Definition at line 110 of file SentNetworkThing.h.

Constructor & Destructor Documentation

◆ SentRequest()

DLLEXPORT SentRequest::SentRequest ( uint32_t  sentinpacket,
uint32_t  messagenumber,
RECEIVE_GUARANTEE  guarantee,
const std::shared_ptr< NetworkRequest > &  request 
)

Definition at line 79 of file SentNetworkThing.cpp.

80  :
81  SentNetworkThing(sentinpacket, messagenumber, guarantee),
82  SentRequestData(request)
83 {}
DLLEXPORT SentNetworkThing(uint32_t packetid, uint32_t messagenumber, RECEIVE_GUARANTEE guarantee)
std::shared_ptr< NetworkRequest > SentRequestData

Member Function Documentation

◆ GetTypeStr()

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

Implements Leviathan::SentNetworkThing.

Definition at line 85 of file SentNetworkThing.cpp.

86 {
87  if(SentRequestData) {
88  return SentRequestData->GetTypeStr();
89  } else {
90  return "null";
91  }
92 }
std::shared_ptr< NetworkRequest > SentRequestData

Member Data Documentation

◆ GotResponse

std::shared_ptr<NetworkResponse> Leviathan::SentRequest::GotResponse

Definition at line 117 of file SentNetworkThing.h.

◆ SentRequestData

std::shared_ptr<NetworkRequest> Leviathan::SentRequest::SentRequestData

Definition at line 119 of file SentNetworkThing.h.


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