示例#1
0
/**
 *  Publish a message to an exchange
 *
 *  @param  exchange    the exchange to publish to
 *  @param  routingkey  the routing key
 *  @param  envelope    the full envelope to send
 *  @param  message     the message to send
 *  @param  size        size of the message
 *  @param  flags
 *  @return DeferredPublisher
 */
DeferredPublisher &ChannelImpl::publish(const std::string &exchange, const std::string &routingKey, const Envelope &envelope, int flags)
{
    // we are going to send out multiple frames, each one will trigger a call to the handler,
    // which in turn could destruct the channel object, we need to monitor that
    Monitor monitor(this);

    // @todo do not copy the entire buffer to individual frames
    
    // make sure we have a deferred object to return
    if (!_publisher) _publisher.reset(new DeferredPublisher(this));

    // send the publish frame
    if (!send(BasicPublishFrame(_id, exchange, routingKey, (flags & mandatory) != 0, (flags & immediate) != 0))) return *_publisher;

    // channel still valid?
    if (!monitor.valid()) return *_publisher;

    // send header
    if (!send(BasicHeaderFrame(_id, envelope))) return *_publisher;

    // channel and connection still valid?
    if (!monitor.valid() || !_connection) return *_publisher;

    // the max payload size is the max frame size minus the bytes for headers and trailer
    uint32_t maxpayload = _connection->maxPayload();
    uint64_t bytessent = 0;

    // the buffer
    const char *data = envelope.body();
    uint64_t bytesleft = envelope.bodySize();

    // split up the body in multiple frames depending on the max frame size
    while (bytesleft > 0)
    {
        // size of this chunk
        uint64_t chunksize = std::min(static_cast<uint64_t>(maxpayload), bytesleft);

        // send out a body frame
        if (!send(BodyFrame(_id, data + bytessent, (uint32_t)chunksize))) return *_publisher;

        // channel still valid?
        if (!monitor.valid()) return *_publisher;

        // update counters
        bytessent += chunksize;
        bytesleft -= chunksize;
    }

    // done
    return *_publisher;
}
示例#2
0
void ArpIntControl::Layout()
{
	inherited::Layout();
	SetDivider(BodyFrame().left - LayoutFrame().left);
}
示例#3
0
void ArpTextControl::LayoutView()
{
	SetDivider(BodyFrame().left - LayoutFrame().left);
}
示例#4
0
void ArpMenuField::LayoutView()
{
	SetDivider(BodyFrame().left - LayoutFrame().left);
}