Core Library 1.7.0.0 Library containing core utilities and tools for threading, networking, logging, INI and CSV file management etc.

Classes | Functions
core_lib::asio::messages Namespace Reference

The tcp namespace. More...

## Classes
struct | ArchiveTypeToEnum
| Archive type enumerator as a template class. More...
struct | ArchiveTypeToEnum< serialize::archives::out_bin_t >
| Archive type enumerator as a specialized template class for binary archives. More...
struct | ArchiveTypeToEnum< serialize::archives::out_json_t >
| Archive type enumerator as a specialized template class for json archives. More...
struct | ArchiveTypeToEnum< serialize::archives::out_port_bin_t >
| Archive type enumerator as a specialized template class for portable binary archives. More...
struct | ArchiveTypeToEnum< serialize::archives::out_protobuf_t >
| Archive type enumerator as a specialized template class for Google protocol buffer data. More...
struct | ArchiveTypeToEnum< serialize::archives::out_raw_t >
| Archive type enumerator as a specialized template class for raw data. More...
struct | ArchiveTypeToEnum< serialize::archives::out_xml_t >
| Archive type enumerators as a specialized template class for xml archives. More...
class | MessageBuilder
| Default message builder class. More...
class | MessageHandler
| Default message handler class. More...

## Functions
void CORE_LIBRARY_DLL_SHARED_API | FillHeader (const std::string &magicString, defs::eArchiveType archiveType, int32_t messageId, const defs::connection_t &responseAddress, uint32_t messageLength, defs::MessageHeader &header)
| Header filler function. More...
template<typename MsgBldr >
defs::char_buffer_t const & | BuildMessage (int32_t messageId, const defs::connection_t &responseAddress, const defs::connection_t &fallbackResponseAddress, const MsgBldr &messageBuilder)
| Message builder wrapper function for header only messages. More...
template<typename MsgBldr >
defs::char_buffer_t const & | BuildMessage (defs::char_buffer_t const &message, int32_t messageId, const defs::connection_t &responseAddress, const defs::connection_t &fallbackResponseAddress, const MsgBldr &messageBuilder)
| Message builder wrapper function for header plus message buffer. More...
template<typename T , typename A , typename MsgBldr >
defs::char_buffer_t const & | BuildMessage (const T &message, int32_t messageId, const defs::connection_t &responseAddress, const defs::connection_t &fallbackResponseAddress, const MsgBldr &messageBuilder)
| Message builder wrapper function for full messages with a header and a body. More...
template<typename T >
T | DeserializeMessage (const defs::char_buffer_t &messageBuffer, defs::eArchiveType archiveType)
| Templated message deserializer function for non-POD data. More...
template<typename T >
T | DeserializeMessage (const defs::char_buffer_t &messageBuffer)
| Templated message deserializer function for POD data. More...
template<typename T >
T | DeserializeProtobuf (const defs::char_buffer_t &messageBuffer)
| Templated message deserializer function for Google protocol buffer data. More...

## Detailed Description

The tcp namespace.

## Function Documentation

## ◆ BuildMessage() [1/3]

template<typename MsgBldr >

defs::char_buffer_t const& core_lib::asio::messages::BuildMessage | ( | int32_t | messageId,
|  | const defs::connection_t & | responseAddress,
|  | const defs::connection_t & | fallbackResponseAddress,
|  | const MsgBldr & | messageBuilder
| ) |  |

Message builder wrapper function for header only messages.

Parameters

  [in] | messageId | - Unique message ID to insert into message header.
  [in] | responseAddress | - The address and port where the server should send the response.
  [in] | fallbackResponseAddress | - The address and port where the server should send the response if the main responseAddress is a NULL_CONNECTION.
  [in] | messageBuilder | - A message builder object of type MsgBldr that must have an interface compatible with that of the class core_lib::asio::messages::MessageBuilder.

Returns
  Returns a const reference to a filled message buffer as a vector of bytes.

This is the "header only" convenience function to build an outgoing network message in all the network classes. It takes a templated arg to provide an actual message builder functor, such as the MessageBuilder functor.

## ◆ BuildMessage() [2/3]

template<typename MsgBldr >

defs::char_buffer_t const& core_lib::asio::messages::BuildMessage | ( | defs::char_buffer_t const & | message,
|  | int32_t | messageId,
|  | const defs::connection_t & | responseAddress,
|  | const defs::connection_t & | fallbackResponseAddress,
|  | const MsgBldr & | messageBuilder
| ) |  |

Message builder wrapper function for header plus message buffer.

Parameters

  [in] | message | - Message buffer.
  [in] | messageId | - Unique message ID to insert into message header.
  [in] | responseAddress | - The address and port where the server should send the response.
  [in] | fallbackResponseAddress | - The address and port where the server should send the response if the main responseAddress is a NULL_CONNECTION.
  [in] | messageBuilder | - A message builder object of type MsgBldr that must have an interface compatible with that of the class core_lib::asio::messages::MessageBuilder.

Returns
  Returns a const reference to a filled message buffer as a vector of bytes.

This is the "header only" convenience function to build an outgoing network message in all the network classes. It takes a templated arg to provide an actual message builder functor, such as the MessageBuilder functor.

## ◆ BuildMessage() [3/3]

template<typename T , typename A , typename MsgBldr >

defs::char_buffer_t const& core_lib::asio::messages::BuildMessage | ( | const T & | message,
|  | int32_t | messageId,
|  | const defs::connection_t & | responseAddress,
|  | const defs::connection_t & | fallbackResponseAddress,
|  | const MsgBldr & | messageBuilder
| ) |  |

Message builder wrapper function for full messages with a header and a body.

Parameters

  [in] | message | - The message of type T to send behind the header serialized to an boost::serialization-compatible archive of type A.
  [in] | messageId | - Unique message ID to insert into message header.
  [in] | responseAddress | - The address and port where the server should send the response.
  [in] | fallbackResponseAddress | - The address and port where the server should send the response if the main responseAddress is a NULL_CONNECTION.
  [in] | messageBuilder | - A message builder object of type MsgBldr that must have an interface compatible with that of the class core_lib::asio::messages::MessageBuilder.

Returns
  Returns a const reference to a filled message buffer as a vector of bytes.

This is the "header plus body" convenience function to build an outgoing network message in all the network classes. It takes a templated arg to provide an actual message builder functor, such as the MessageBuilder functor. This variant as stated is for header only messages.

## ◆ DeserializeMessage() [1/2]

template<typename T >

T core_lib::asio::messages::DeserializeMessage | ( | const defs::char_buffer_t & | messageBuffer,
|  | defs::eArchiveType | archiveType
| ) |  |

Templated message deserializer function for non-POD data.

Parameters

  [in] | messageBuffer | - Message buffer to be deserialized.
  [in] | archiveType | - Serialization archive type.

Returns
  The deserialization object T.

## ◆ DeserializeMessage() [2/2]

template<typename T >

T core_lib::asio::messages::DeserializeMessage | ( | const defs::char_buffer_t & | messageBuffer | ) |

Templated message deserializer function for POD data.

Parameters

  [in] | messageBuffer | - Message buffer to be deserialized.

Returns
  The deserialization object T.

## ◆ DeserializeProtobuf()

template<typename T >

T core_lib::asio::messages::DeserializeProtobuf | ( | const defs::char_buffer_t & | messageBuffer | ) |

Templated message deserializer function for Google protocol buffer data.

Parameters

  [in] | messageBuffer | - Message buffer to be deserialized.

Returns
  The deserialization object T.

## ◆ FillHeader()

void core_lib::asio::messages::FillHeader | ( | const std::string & | magicString,
|  | defs::eArchiveType | archiveType,
|  | int32_t | messageId,
|  | const defs::connection_t & | responseAddress,
|  | uint32_t | messageLength,
|  | defs::MessageHeader & | header
| ) |  |

Header filler function.

Parameters

  [in] | magicString | - A received message buffer.
  [in] | archiveType | - The archive type used for message serialization.
  [in] | messageId | - The unique message ID.
  [in] | responseAddress | - The response connection details describing sender's address and port.
  [in] | messageLength | - The length of the message not including the header.
  [out] | header | - The message header to be filled out.

Returns
  A filled message header.

This is an example of a function used within the network clases to build the message header that is always prepended to the message to be sent over a socket. It is used in the simple network classes, e.g. SimpleTcpClient, SimpleTcpServer etc., via the MessageBuilder functor.

This function only works with headers of the type MessageHeader.