int size = currentWriteBuffer.remaining(); if (size > 0) { writerState.getCommand().setChannelId(channelId); writerState.getCommand().setCommandType(MuxDemuxCommand.CommandType.DATA); writerState.getCommand().setData(size); writerState.reset(currentWriteBuffer, size, ccb); } else { adjustChannelWritability(); writerState.getCommand().setChannelId(channelId); writerState.getCommand().setCommandType(MuxDemuxCommand.CommandType.ERROR); writerState.getCommand().setData(REMOTE_ERROR_CODE); writerState.reset(null, 0, null); ecodeSent = true; ccb.reportLocalEOS(); adjustChannelWritability(); } else if (isPendingCloseWrite()) { writerState.getCommand().setChannelId(channelId); writerState.getCommand().setCommandType(MuxDemuxCommand.CommandType.CLOSE_CHANNEL); writerState.getCommand().setData(0); writerState.reset(null, 0, null); eosSent = true; ccb.reportLocalEOS();
if (size > 0) { credits -= size; writerState.getCommand().setChannelId(channelId); writerState.getCommand().setCommandType(MuxDemuxCommand.CommandType.DATA); writerState.getCommand().setData(size); writerState.reset(currentWriteBuffer, size, ccb); } else { adjustChannelWritability(); writerState.getCommand().setChannelId(channelId); writerState.getCommand().setCommandType(MuxDemuxCommand.CommandType.ERROR); writerState.getCommand().setData(REMOTE_ERROR_CODE); writerState.reset(null, 0, null); ecodeSent = true; ccb.reportLocalEOS(); adjustChannelWritability(); } else if (isPendingCloseWrite()) { writerState.getCommand().setChannelId(channelId); writerState.getCommand().setCommandType(MuxDemuxCommand.CommandType.CLOSE_CHANNEL); writerState.getCommand().setData(0); writerState.reset(null, 0, null); eosSent = true; ccb.reportLocalEOS();