Thanks for the suggestion !
I think it is reasonable however for a websocket to accept just text
messages, just binary messages, or to opt to handle text messages using
one method and binary messages another - I think all approaches are valid.
I think in general we're trying to opt for single method interfaces for
this so that when we can move to JDK 8, people can handle them with lambdas.
The single interface would definitely mean a smaller API in terms of
classes, but looks like it would require developers to think about
implementing handlers for messages they weren't interested in or knew
the client wouldn't ever send.
Best,
- Danny
On 11/27/12 7:49 AM, ghsutanu_at_gmail.com wrote:
> What is the usecase for having different MessageHandler objects for
> different message/frame types ?
>
> IMO, it would have been much simpler if the MessageHandler interface is
> the unified handler for all types of websocket messages.
>
> interface MessageHandler {
>
> void onMessage(String textMessage);
>
> void onMessage(ByteBuffer binaryMessage)
>
> void onMessage(String textFrame,
> boolean last)
>
> void onMessage(String binaryFrame,
> boolean last)
>
> etc...
> }
>
> In this model, there will be a single MessageHandler per websocket
> (Session).
--
<http://www.oracle.com> *Danny Coward *
Java EE
Oracle Corporation