[ 
https://issues.apache.org/jira/browse/DIRMINA-907?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13873086#comment-13873086
 ] 

dhruv chopra commented on DIRMINA-907:
--------------------------------------

Andres, you are right that there is an issue. However code you suggest has 
another issue. Instead of buf.capacity() - you need to check buf.limit() while 
comparing with 125.

{code:title=Bar.java|borderStyle=solid}
    // Encode the in buffer according to the Section 5.2. RFC 6455
    private static IoBuffer buildWSDataFrameBuffer(IoBuffer buf) {
        
        IoBuffer buffer = IoBuffer.allocate(buf.limit() + 2, false);
        buffer.setAutoExpand(true);
        buffer.put((byte) 0x82);
        if(buf.limit() <= 125){
            byte capacity = (byte) (buf.limit());
            buffer.put(capacity);
        }
        else{
            buffer.put((byte)126);
            buffer.putShort((short)buf.limit());
        }                
        buffer.put(buf);
        buffer.flip();
        return buffer;
    }
{code}

> Create a WebSocket iofilter for use in Apache Mina TCP servers
> --------------------------------------------------------------
>
>                 Key: DIRMINA-907
>                 URL: https://issues.apache.org/jira/browse/DIRMINA-907
>             Project: MINA
>          Issue Type: New Feature
>          Components: Filter, Protocol - HTTP, Transport
>            Reporter: dhruv chopra
>         Attachments: MinaCodecUsage.png, WebSocketFilter.zip
>
>
> Shephertz has created a websocket iofilter that can be added in Apache mina 
> tcp server chain. The features of this codec are
> 1) Works with binary data sent/received over websocket
> 2) Abstracts the client details from the Handler code i.e. the handler need 
> not be aware that the remote endpoint is a browser or native client.
> 3) Tested with binary data sent/received on latest chrome and firefox 
> browsers. IE 9 doesn't support websockets and we will make changes if 
> required for IE 10 when its released and if it supports websockets.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to