kaazing / netx

Network utility that extends java.net, including URL
Apache License 2.0
10 stars 6 forks source link

New MessageReader and MessageWriter API and implementation #38

Closed sanjay-saxena closed 9 years ago

sanjay-saxena commented 9 years ago

to support messages that fit in a single WebSocket frame and messages that span across multiple WebSocket frames.

jfallows commented 9 years ago

Are the scripts under ws/src/test/scripts still needed by anything?

sanjay-saxena commented 9 years ago

ws/src/test/scripts contains scripts for extension related tests and other tests that try to simulate metadata bytes split across different chunks.

jfallows commented 9 years ago

If we had randomized fragmentation support in k3po would those split bytes tests still be needed?

jfallows commented 9 years ago

What is being tested in the extension scripts that is not already covered by the specification scripts?

jfallows commented 9 years ago

The FIN bit feedback above doesn't seem to be addressed yet.

sanjay-saxena commented 9 years ago

If we have randomized fragmentation support in k3po, then we can get rid of the split bytes test from netx. The extension tests simulate removing a certain prefix from the outgoing frame and then adding a certain prefix for incoming frame.

Here is the FIN feedback from above:

FIN bit should be set on close(), not flush(), right?

I have implemented this in the OutputStream and Reader implementations that are embedded in WsMessageWriter. Here is the close() method in embedded OutputStream implementation that is within WsMessageWriter:

       @Override
        public void close() throws IOException {
            try {
                lock.lock();

                if (initialFrame) {
                    // Only one frame in the message.
                    connection.getOutputStream().write(binaryBuffer, 0, binaryBufferOffset);
                }
                else {
                    // Send the final frame.
                    connection.getOutputStream().writeBinary(CONTINUATION, binaryBuffer, 0, binaryBufferOffset, true);
                }
                initialFrame = true;
                binaryBufferOffset = 0;
            }
            finally {
                lock.unlock();
            }
        }
jfallows commented 9 years ago

Excellent work @sanjay-saxena. 😎