Skip to content

Commit bc1cee3

Browse files
committed
removed final modifier and added catch clause for exceptions thrown from user-implemented method onMessage
1 parent f2b26e1 commit bc1cee3

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

‎src/org/java_websocket/WebSocketImpl.java‎

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* <i>onClientMessage</i> callbacks.
4848
*
4949
*/
50-
public final class WebSocketImpl extends WebSocket {
50+
public class WebSocketImpl extends WebSocket {
5151

5252
/**
5353
* Determines whether to receive data as part of the
@@ -105,7 +105,6 @@ public final class WebSocketImpl extends WebSocket {
105105
* they occur.
106106
*/
107107

108-
109108
public WebSocketImpl( WebSocketListener listener , List<Draft> drafts , Socket sock ) {
110109
this( listener, (Draft) null, sock );
111110
this.role = Role.SERVER;
@@ -599,14 +598,18 @@ private void write( List<ByteBuffer> bufs ) {
599598
}
600599

601600
private void deliverMessage( Framedata d ) throws InvalidDataException {
602-
if( d.getOpcode() == Opcode.TEXT ) {
603-
wsl.onWebsocketMessage( this, Charsetfunctions.stringUtf8( d.getPayloadData() ) );
604-
} else if( d.getOpcode() == Opcode.BINARY ) {
605-
wsl.onWebsocketMessage( this, d.getPayloadData() );
606-
} else {
607-
if( DEBUG )
608-
System.out.println( "Ignoring frame:" + d.toString() );
609-
assert ( false );
601+
try {
602+
if( d.getOpcode() == Opcode.TEXT ) {
603+
wsl.onWebsocketMessage( this, Charsetfunctions.stringUtf8( d.getPayloadData() ) );
604+
} else if( d.getOpcode() == Opcode.BINARY ) {
605+
wsl.onWebsocketMessage( this, d.getPayloadData() );
606+
} else {
607+
if( DEBUG )
608+
System.out.println( "Ignoring frame:" + d.toString() );
609+
assert ( false );
610+
}
611+
} catch ( RuntimeException e ) {
612+
wsl.onWebsocketError( this, e );
610613
}
611614
}
612615

0 commit comments

Comments
 (0)