private void processReply(IStream stream, SynReplyFrame frame) { stream.process(frame); if (stream.isClosed()) removeStream(stream); }
@Override public void shutdown() { CloseFrameBytes frameBytes = new CloseFrameBytes(); flush(frameBytes, flusher.append(frameBytes)); }
@Override public void push(PushInfo pushInfo, Promise<Stream> promise) { notIdle(); if (isClosed() || isReset()) { close(); promise.failed(new StreamException(getId(), StreamStatus.STREAM_ALREADY_CLOSED, "Stream: " + this + " already closed or reset!")); return; } PushSynInfo pushSynInfo = new PushSynInfo(getId(), pushInfo); session.syn(pushSynInfo, null, new StreamPromise(promise)); }
@Override public void onSessionException(SessionException x) { Throwable cause = x.getCause(); notifyOnFailure(listener, cause == null ? x : cause); goAway(x.getSessionStatus(), 0, TimeUnit.SECONDS, Callback.Adapter.INSTANCE); }
@Override public int compareTo(FrameBytes that) { // FrameBytes may have or not have a related stream (for example, PING do not have a related stream) // FrameBytes without related streams have higher priority IStream thisStream = getStream(); IStream thatStream = that.getStream(); if (thisStream == null) return thatStream == null ? 0 : -1; if (thatStream == null) return 1; // If this.stream.priority > that.stream.priority => this.stream has less priority than that.stream return thatStream.getPriority() - thisStream.getPriority(); }
@Override public void setWindowSize(ISession session, int windowSize) { int prevWindowSize = this.windowSize; this.windowSize = windowSize; for (Stream stream : session.getStreams()) ((IStream)stream).updateWindowSize(windowSize - prevWindowSize); }
private void checkVersion(short version, int streamId) { if (version != SPDY.V2 && version != SPDY.V3) throw new StreamException(streamId, StreamStatus.UNSUPPORTED_VERSION); }
@Override public void onNewStream(ISession session, IStream stream) { stream.updateWindowSize(windowSize); }
@Override public void goAway(GoAwayInfo goAwayInfo) throws ExecutionException, InterruptedException, TimeoutException { goAway(goAwayInfo, SessionStatus.OK); }
@Override public void control(IStream stream, ControlFrame frame, long timeout, TimeUnit unit, Callback callback) { generateAndEnqueueControlFrame(stream, frame, timeout, unit, callback); }
private void close() { closeState = CloseState.CLOSED; onClose(); }
@Override public Compressor newCompressor() { return new StandardCompressor(); }
private void checkSlotValid() { if (slot <= 0) throw new SessionException(SessionStatus.PROTOCOL_ERROR, "Invalid slot " + slot + " for " + ControlFrameType.CREDENTIAL + " frame"); }
protected void close() { // Check for null to support tests if (controller != null) controller.close(false); }
private void processHeaders(IStream stream, HeadersFrame frame) { stream.process(frame); if (stream.isClosed()) removeStream(stream); }
@Override public void onWindowUpdate(ISession session, IStream stream, int delta) { if (stream != null) stream.updateWindowSize(delta); }
@Override public void updateWindow(ISession session, IStream stream, int delta) { stream.updateWindowSize(delta); }
@Override public void onNewStream(ISession session, IStream stream) { stream.updateWindowSize(windowSize); }