aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/poco/MongoDB/src/RequestMessage.cpp
blob: 6391d9661985a7271223eda5af11964ed3287bb7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// 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 {


RequestMessage::RequestMessage(MessageHeader::OpCode opcode): 
	Message(opcode)
{
}


RequestMessage::~RequestMessage()
{
}


void RequestMessage::send(std::ostream& ostr)
{
	std::stringstream ss;
	BinaryWriter requestWriter(ss);
	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