Library: MongoDB
Package: MongoDB
Header: Poco/MongoDB/MessageHeader.h
Description
Represents the message header which is always prepended to a MongoDB request or response message.
INTERNAL: This class is an implementation detail of the MongoDB protocol and not intended for direct use.
Member Summary
Member Functions: getMessageLength, getRequestID, opCode, read, responseTo, setRequestID, write
Enumerations
OpCode
Opcodes supported in MongoDB 5.1 and later
OP_COMPRESSED = 2012
OP_MSG = 2013
Constructors
MessageHeader
explicit MessageHeader(
OpCode
);
Creates the MessageHeader using the given OpCode.
Destructor
~MessageHeader
virtual ~MessageHeader();
Destroys the MessageHeader.
Member Functions
getMessageLength
[[nodiscard]]
Int32 getMessageLength() const;
Returns the message length.
getRequestID
[[nodiscard]]
Int32 getRequestID() const;
Returns the request ID of the current message.
opCode
[[nodiscard]]
OpCode opCode() const;
Returns the OpCode.
read
void read(
BinaryReader & reader
);
Reads the header using the given BinaryReader.
responseTo
[[nodiscard]]
Int32 responseTo() const;
Returns the request id from the original request.
setRequestID
void setRequestID(
Int32 id
);
Sets the request ID of the current message.
write
void write(
BinaryWriter & writer
);
Writes the header using the given BinaryWriter.
Variables
MSG_HEADER_SIZE
static constexpr Int32 MSG_HEADER_SIZE = 16;