@Override public void data(DataInfo dataInfo) throws InterruptedException, ExecutionException, TimeoutException { FutureCallback result = new FutureCallback(); data(dataInfo, result); if (dataInfo.getTimeout() > 0) result.get(dataInfo.getTimeout(), dataInfo.getUnit()); else result.get(); }
@Override public void data(DataInfo dataInfo, Callback callback) { notIdle(); if (!canSend()) { session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR), new StreamCallback()); throw new IllegalStateException("Protocol violation: cannot send a DATA frame before a SYN_REPLY frame"); } if (isLocallyClosed()) { session.rst(new RstInfo(getId(), StreamStatus.PROTOCOL_ERROR), new StreamCallback()); throw new IllegalStateException("Protocol violation: cannot send a DATA frame on a locally closed stream"); } // Cannot update the close state here, because the data that we send may // be flow controlled, so we need the stream to update the window size. session.data(this, dataInfo, dataInfo.getTimeout(), dataInfo.getUnit(), new StreamCallback(callback)); }