File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
src/net/tootallnate/websocket Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 11package net .tootallnate .websocket ;
22
33import java .io .IOException ;
4+ import java .io .UnsupportedEncodingException ;
45import java .nio .ByteBuffer ;
56import java .nio .channels .NotYetConnectedException ;
67import java .nio .channels .SocketChannel ;
@@ -31,7 +32,7 @@ public final class WebSocket {
3132 /**
3233 * The WebSocket protocol expects UTF-8 encoded bytes.
3334 */
34- public static final Charset UTF8_CHARSET = Charset . forName ( "UTF-8" ) ;
35+ public static final String UTF8_CHARSET = "UTF-8" ;
3536 /**
3637 * The byte representing CR, or Carriage Return, or \r
3738 */
@@ -224,7 +225,13 @@ private void recieveFrame() {
224225 // currentFrame will be null if END_OF_FRAME was send directly after
225226 // START_OF_FRAME, thus we will send 'null' as the sent message.
226227 if (this .currentFrame != null ) {
227- textFrame = new String (this .currentFrame .array (), UTF8_CHARSET );
228+ try {
229+ textFrame = new String (this .currentFrame .array (), UTF8_CHARSET );
230+ } catch (UnsupportedEncodingException ex ) {
231+ // TODO: Fire an 'onError' handler here
232+ ex .printStackTrace ();
233+ textFrame = "" ;
234+ }
228235 }
229236 this .wsl .onMessage (this , textFrame );
230237
You can’t perform that action at this time.
0 commit comments