@Override public void write(final ByteBufferList list) { if (mServer.getAffinity() != Thread.currentThread()) { mServer.run( new Runnable() { @Override public void run() { write(list); } }); return; } if (!mChannel.isConnected()) { assert !mChannel.isChunked(); return; } try { int before = list.remaining(); ByteBuffer[] arr = list.getAllArray(); mChannel.write(arr); list.addAll(arr); handleRemaining(list.remaining()); mServer.onDataSent(before - list.remaining()); } catch (IOException e) { closeInternal(); reportEndPending(e); reportClose(e); } }
@Override public void write(final ByteBuffer b) { if (mServer.getAffinity() != Thread.currentThread()) { mServer.run( new Runnable() { @Override public void run() { write(b); } }); return; } try { if (!mChannel.isConnected()) { assert !mChannel.isChunked(); return; } // keep writing until the the socket can't write any more, or the // data is exhausted. int before = b.remaining(); mChannel.write(b); handleRemaining(b.remaining()); mServer.onDataSent(before - b.remaining()); } catch (IOException ex) { closeInternal(); reportEndPending(ex); reportClose(ex); } }