Class Poco::MongoDB::MessageHeader
Author: Applied Informatics Software Engineering GmbH and Contributors

# Poco::MongoDB

# class MessageHeader

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.

## Member Summary

Member Functions: getMessageLength, getRequestID, opCode, read, responseTo, setRequestID, write

## Enumerations

### OpCode

OP_REPLY = 1

OP_MSG = 1000

OP_UPDATE = 2001

OP_INSERT = 2002

OP_QUERY = 2004

OP_GET_MORE = 2005

OP_DELETE = 2006

OP_KILL_CURSORS = 2007

## Constructors

### MessageHeader

explicit MessageHeader(
OpCode
);

Creates the MessageHeader using the given OpCode.

## Destructor

### ~MessageHeader

virtual ~MessageHeader();

Destroys the MessageHeader.

## Member Functions

### getMessageLength

Int32 getMessageLength() const;

Returns the message length.

### getRequestID

Int32 getRequestID() const;

Returns the request ID of the current message.

### opCode

OpCode opCode() const;

Returns the OpCode.

### read

void read(
BinaryReader & reader
);

Reads the header using the given BinaryReader.

### responseTo

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 const unsigned int MSG_HEADER_SIZE = 16;