Ejemplo n.º 1
0
  private void write(ByteBuffer buf) {
    if (DEBUG)
      System.out.println(
          "write("
              + buf.remaining()
              + "): {"
              + (buf.remaining() > 1000 ? "too big to display" : new String(buf.array()))
              + "}");

    outQueue.add(buf);
    /*try {
    	outQueue.put( buf );
    } catch ( InterruptedException e ) {
    	write( buf );
    	Thread.currentThread().interrupt(); // keep the interrupted status
    	e.printStackTrace();
    }*/
    wsl.onWriteDemand(this);
  }
Ejemplo n.º 2
0
  protected synchronized void flushAndClose(int code, String message, boolean remote) {
    if (flushandclosestate) {
      return;
    }
    closecode = code;
    closemessage = message;
    closedremotely = remote;

    flushandclosestate = true;

    wsl.onWriteDemand(
        this); // ensures that all outgoing frames are flushed before closing the connection
    try {
      wsl.onWebsocketClosing(this, code, message, remote);
    } catch (RuntimeException e) {
      wsl.onWebsocketError(this, e);
    }
    if (draft != null) draft.reset();
    handshakerequest = null;
  }