public boolean isClosed() { return getServiceState() == STOPPED; }
public boolean full() { return codec==null || codec.full() || !socketState.is(CONNECTED.class) || getServiceState() != STARTED; }
public void drainInbound() { if (!getServiceState().isStarted() || readSource.isSuspended()) { return; } try { long initial = codec.getReadCounter(); // Only process upto 2 x the read buffer worth of data at a time so we can give // other connections a chance to process their requests. while( codec.getReadCounter()-initial < codec.getReadBufferSize()<<2 ) { Object command = codec.read(); if ( command!=null ) { try { listener.onTransportCommand(command); } catch (Throwable e) { e.printStackTrace(); onTransportFailure(new IOException("Transport listener failure.")); } // the transport may be suspended after processing a command. if (getServiceState() == STOPPED || readSource.isSuspended()) { return; } } else { return; } } yieldSource.merge(1); } catch (IOException e) { onTransportFailure(e); } }
/** * */ public void flush() { dispatchQueue.assertExecuting(); if (getServiceState() != STARTED || !socketState.is(CONNECTED.class)) { return; } try { if( codec.flush() == ProtocolCodec.BufferState.EMPTY && transportFlush() ) { if( writeResumedForCodecFlush) { writeResumedForCodecFlush = false; suspendWrite(); } rejectingOffers = false; listener.onRefill(); } else { if(!writeResumedForCodecFlush) { writeResumedForCodecFlush = true; resumeWrite(); } } } catch (IOException e) { onTransportFailure(e); } }