2
* Aggregates individual serialized XML::Events into larger packages
3
* for more efficient delivery
6
* David Yip <yipdw@rose-hulman.edu>
8
* Copyright (c) 2005 Authors
10
* Released under GNU GPL, read the file 'COPYING' for more information
14
#include "jabber_whiteboard/message-aggregator.h"
18
namespace Whiteboard {
21
MessageAggregator::addOne(Glib::ustring const& msg, Glib::ustring& buf)
23
// 1. If msg.bytes() > maximum size and the buffer is clear,
24
// then we have to send an oversize packet --
25
// we won't be able to deliver the message any other way.
26
// Add it to the buffer and return true. Any further attempt to
27
// aggregate a message will be handled by condition #2.
28
if (msg.bytes() > MessageAggregator::MAX_SIZE && buf.empty()) {
33
// 2. If msg.bytes() + buf.bytes() > maximum size, return false.
34
// The user of this class is responsible for retrieving the aggregated message,
35
// doing something with it, clearing the buffer, and trying again.
36
// Otherwise, append the message to the buffer and return true.
37
if (msg.bytes() + buf.bytes() > MessageAggregator::MAX_SIZE) {
46
MessageAggregator::addOne(Glib::ustring const& msg)
48
return this->addOne(msg, this->_buf);
58
c-file-style:"stroustrup"
59
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
64
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :