Esempio n. 1
0
 /**
  * Convert text back to string
  *
  * @see java.lang.Object#toString()
  */
 public String toString() {
   try {
     return decode(bytes, 0, length);
   } catch (CharacterCodingException e) {
     throw new RuntimeException("Should not have happened " + e.toString());
   }
 }
Esempio n. 2
0
 /** Set to contain the contents of a string. */
 public void set(String string) {
   try {
     ByteBuffer bb = encode(string, true);
     bytes = bb.array();
     length = bb.limit();
   } catch (CharacterCodingException e) {
     throw new RuntimeException("Should not have happened " + e.toString());
   }
 }
Esempio n. 3
0
 private void readWebsocket() {
   try {
     while (this.state == State.OPEN) {
       handleWebsocketFrame(WebSocketFrame.read(this.in));
     }
   } catch (CharacterCodingException e) {
     onException(e);
     doClose(CloseCode.InvalidFramePayloadData, e.toString(), false);
   } catch (IOException e) {
     onException(e);
     if (e instanceof WebSocketException) {
       doClose(((WebSocketException) e).getCode(), ((WebSocketException) e).getReason(), false);
     }
   } finally {
     doClose(
         CloseCode.InternalServerError,
         "Handler terminated without closing the connection.",
         false);
   }
 }