8 #ifndef FACEBOOK_NETWORK_PACKAGED_CONNECTIONLESS_SERVER_H
9 #define FACEBOOK_NETWORK_PACKAGED_CONNECTIONLESS_SERVER_H
76 inline MessageData(
const Timestamp retireTimestamp,
const size_t size,
const unsigned int remainingPackages);
88 inline unsigned int remainingPackages()
const;
94 inline size_t size()
const;
100 inline const uint8_t* buffer()
const;
106 inline uint8_t* buffer();
112 inline void setRetireTimestamp(
const Timestamp timestamp);
118 inline void setRemaininigPackages(
const unsigned int packages);
140 unsigned int remainingPackages_ = 0u;
165 inline const Address4& address()
const;
171 inline const Port& port()
const;
184 inline bool operator<(
const Triple& triple)
const;
195 unsigned int messageId_ = invalidMessageId();
235 double maximalMessageTime_ = 5.0;
245 retireTimestamp_(messageData.retireTimestamp_),
246 remainingPackages_(messageData.remainingPackages_),
247 buffer_(messageData.buffer_)
253 retireTimestamp_(messageData.retireTimestamp_),
254 remainingPackages_(messageData.remainingPackages_),
255 buffer_(std::move(messageData.buffer_))
257 messageData.retireTimestamp_.toInvalid();
258 messageData.remainingPackages_ = 0u;
262 retireTimestamp_(retireTimestamp),
263 remainingPackages_(remainingPackages),
271 return retireTimestamp_;
276 return remainingPackages_;
296 retireTimestamp_ = timestamp;
301 remainingPackages_ = packages;
315 if (
this != &messageData)
318 remainingPackages_ = messageData.remainingPackages_;
319 buffer_ = std::move(messageData.buffer_);
321 messageData.retireTimestamp_.toInvalid();
322 messageData.remainingPackages_ = 0u;
331 messageId_(messageId)
This class wraps an address number with 32 bits.
Definition: Address4.h:26
This class is the base class for all packaged connectionless clients.
Definition: PackagedConnectionlessClient.h:31
This class implements a message.
Definition: PackagedConnectionlessServer.h:50
unsigned int remainingPackages() const
Returns the number of remaining packages.
Definition: PackagedConnectionlessServer.h:274
const uint8_t * buffer() const
Returns the message buffer.
Definition: PackagedConnectionlessServer.h:284
Buffer buffer_
The entire buffer of the message.
Definition: PackagedConnectionlessServer.h:143
MessageData & operator=(const MessageData &messageData)
Assign operator.
Definition: PackagedConnectionlessServer.h:304
void setRetireTimestamp(const Timestamp timestamp)
Sets or changes the retire timestamp.
Definition: PackagedConnectionlessServer.h:294
void setRemaininigPackages(const unsigned int packages)
Sets the number of packages which are still missing.
Definition: PackagedConnectionlessServer.h:299
Timestamp retireTimestamp() const
Returns the retire timestamp.
Definition: PackagedConnectionlessServer.h:269
Timestamp retireTimestamp_
The timestamp at which this message will be retired as no further packages arrived in the meantime.
Definition: PackagedConnectionlessServer.h:137
MessageData()=default
Creates an empty data object.
size_t size() const
Returns the size of the message buffer, in bytes.
Definition: PackagedConnectionlessServer.h:279
unsigned int remainingPackages_
The number of packages which are still missing.
Definition: PackagedConnectionlessServer.h:140
Definition of a triple storing an address, a port and a message id.
Definition: PackagedConnectionlessServer.h:150
Triple(const Address4 &address, const Port &port, const MessageId messageId)
Creates a new triple object.
Definition: PackagedConnectionlessServer.h:328
bool operator<(const Triple &triple) const
Compares two triple objects.
Definition: PackagedConnectionlessServer.h:351
unsigned int messageId_
The message id of this object.
Definition: PackagedConnectionlessServer.h:195
const Address4 & address() const
Returns the address of this object.
Definition: PackagedConnectionlessServer.h:336
MessageId messageId() const
Returns the message id of this object.
Definition: PackagedConnectionlessServer.h:346
const Port & port() const
Returns the port of this object.
Definition: PackagedConnectionlessServer.h:341
Address4 address_
The address of this object.
Definition: PackagedConnectionlessServer.h:189
Port port_
The port of this object.
Definition: PackagedConnectionlessServer.h:192
This class is the base class for all package connectionless server.
Definition: PackagedConnectionlessServer.h:31
bool onScheduler() override
The scheduler event function.
ReceiveCallback receiveCallback_
Data callback function called on new message arrivals.
Definition: PackagedConnectionlessServer.h:232
~PackagedConnectionlessServer() override
Destructs a connectionless server object.
void setReceiveCallback(const ReceiveCallback &callback)
Sets the receive data callback function.
Definition: PackagedConnectionlessServer.h:356
Callback< void, const Address4 &, const Port &, const void *, const size_t, const MessageId > ReceiveCallback
Definition of a data callback function.
Definition: PackagedConnectionlessServer.h:42
MessageMap connectionlessServerMessageMap
The map holding all partially received message.
Definition: PackagedConnectionlessServer.h:241
Buffer packageBuffer_
Intermediate buffer storing individual parts of a large message.
Definition: PackagedConnectionlessServer.h:238
std::map< Triple, MessageData > MessageMap
Definition of a map mapping message ids to massage data objects.
Definition: PackagedConnectionlessServer.h:201
PackagedConnectionlessServer()
Creates a new connectionless server object.
uint32_t MessageId
Definition of a message id.
Definition: PackagedSocket.h:185
This class wraps a port number with 16 bits.
Definition: Port.h:26
This class is the base class for all server.
Definition: Server.h:26
Buffer buffer_
The socket buffer of this server.
Definition: Server.h:57
Address4 address() const
Returns the own address of this socket.
std::vector< uint8_t > Buffer
Definition of a vector holding 8 bit values.
Definition: Socket.h:76
Port port() const
Returns the own port of this socket.
Lock lock_
Socket lock.
Definition: Socket.h:187
This class implements a scoped lock object for recursive lock objects.
Definition: Lock.h:135
This class implements a timestamp.
Definition: Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15