Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Continuation Frame

Hi,

On Tue, Oct 13, 2015 at 9:39 AM, Muhui Jiang <jiangmuhui@xxxxxxxxx> wrote:
> Hi,
>
> Simone, Thanks for your detailed suggestions.
> So in your code, you mean
>
> List<ByteBuffer> buffers = lease.getByteBuffers();
>
> the list is the whole Continuation frames?

No.
It contains a list of buffers to write.
The buffers are typically 2 per frame: 1 buffer containing the header
bytes, 1 buffer containing the body bytes.

> But how can I write the continuation frame to the server periodically. I
> tried to use
>
> session.newStream(headers,
>
> new Promise.Adapter<>(), new Stream.Listener.Adapter() {}
>
> this way to send the headers but the result is that I can get the whole
> headersframe immediately.

Sure that will send a whole HEADERS frame.

You need to generate the buffers with the Generator and then write the
buffers one at a time.

> My question is how to write the buffer(Continuation frame) into the server
> periodically then the server can not get my whole headers frame in a short
> time. Many thanks.

List<ByteBuffer> buffers = lease.getByteBuffers();
for (ByteBuffer buffer : buffers)
{
    socketChannel.write(buffer);
    Thread.sleep(1000);
}

Alternatively, you can just generate the buffers and then continuously
send the same couple of buffers over and over.

buffers[0] = HEADERS header bytes
buffers[1] = HEADERS body bytes
buffers[2] = CONTINUATION #1 headers bytes
buffers[3] = CONTINUATION #1 body bytes
buffers[4] = CONTINUATION #2 headers bytes
buffers[5] = CONTINUATION #2 body bytes
etc.

-- 
Simone Bordet
----
http://cometd.org
http://webtide.com
Developer advice, training, services and support
from the Jetty & CometD experts.


Back to the top