2023-02-08 11:04:11 +00:00
|
|
|
//
|
|
|
|
// RequestMessage.cpp
|
|
|
|
//
|
|
|
|
// Library: MongoDB
|
|
|
|
// Package: MongoDB
|
|
|
|
// Module: RequestMessage
|
|
|
|
//
|
|
|
|
// Copyright (c) 2012, Applied Informatics Software Engineering GmbH.
|
|
|
|
// and Contributors.
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include "Poco/MongoDB/RequestMessage.h"
|
|
|
|
#include "Poco/Net/SocketStream.h"
|
|
|
|
#include "Poco/StreamCopier.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace Poco {
|
|
|
|
namespace MongoDB {
|
|
|
|
|
|
|
|
|
2023-05-22 02:02:09 +00:00
|
|
|
RequestMessage::RequestMessage(MessageHeader::OpCode opcode):
|
2023-02-08 11:04:11 +00:00
|
|
|
Message(opcode)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RequestMessage::~RequestMessage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void RequestMessage::send(std::ostream& ostr)
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
2023-05-22 02:02:09 +00:00
|
|
|
BinaryWriter requestWriter(ss, BinaryWriter::LITTLE_ENDIAN_BYTE_ORDER);
|
2023-02-08 11:04:11 +00:00
|
|
|
buildRequest(requestWriter);
|
|
|
|
requestWriter.flush();
|
|
|
|
|
|
|
|
messageLength(static_cast<Poco::Int32>(ss.tellp()));
|
|
|
|
|
|
|
|
BinaryWriter socketWriter(ostr, BinaryWriter::LITTLE_ENDIAN_BYTE_ORDER);
|
|
|
|
_header.write(socketWriter);
|
|
|
|
StreamCopier::copyStream(ss, ostr);
|
|
|
|
ostr.flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} } // namespace Poco::MongoDB
|