mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark Phillips (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DIRMINA-907) Create a WebSocket iofilter for use in Apache Mina TCP servers
Date Fri, 06 Sep 2013 00:24:52 GMT

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

Mark Phillips commented on DIRMINA-907:
---------------------------------------

The WebSocketEncoder.java class as submitted conflicts with its documentation.  As commented
it should encode output in WS DataFrames when the receiving client is known to be a WebSocket.
 When the receiving client is native it should pass through incoming IoBuffers unchanged.
 This makes sense assuming this encoder is part of a filter chain, presumably the last one
before wire transmission.  However the pass-through logic is not implemented in the code submitted.
 If the message is not already a WS type an  Exception is thrown.  The comment logic seems
correct to me, the implementation incorrect.

Additionally, WebSocketEncoder.encode() will never be called if MINA is configured in a way
which conforms to the code's commented intention.  In my environment I have MINA configured
this way:

IoAcceptor server = new NioSocketAcceptor();

server.getFilterChain().addLast("WSCodec", new ProtocolCodecFilter(new WebSocketCodecFactory()));

server.getFilterChain().addLast("TextLineCodec", new ProtocolCodecFilter(new TextLineCodecFactory(Charset.forName("UTF-8"))));

server.getFilterChain().addLast("threadPool", new ExecutorFilter(Executors.newCachedThreadPool()));

server.setHandler(new <your custom MINA IoHandler here>);

The WebSocketCodecFactory is here simply added at the end of the already-existing chain which
has worked happily for years.  I think this conforms with the developers' intentions.

But, WebSocketEncoder.encode() will never be invoked, because when ProtocolCodecFilter.filterWrite()
tests that its input WriteRequest.getMessage() is instanceof IoBuffer, it'll assume encoding
is complete, hand the WriteRequest to the next filter, and return.

It's possible I've misunderstood the developers' deployment intentions?
                
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Mime
View raw message