@Override public void channelRead(ChannelHandlerContext chctx, Object msg) throws Exception { context.executeFromIO(msg, messageHandler); }
@Override public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { context.executeFromIO(endReadAndFlush); }
@Override public void onSettingsAckRead(ChannelHandlerContext ctx) { Handler<Void> handler; synchronized (this) { handler = updateSettingsHandlers.poll(); } if (handler != null) { // No need to run on a particular context it shall be done by the handler instead context.executeFromIO(handler); } }
@Override public void channelInactive(ChannelHandlerContext chctx) throws Exception { if (removeHandler != null) { removeHandler.handle(conn); } context.executeFromIO(v -> conn.handleClosed()); }
@Override public void onPingRead(ChannelHandlerContext ctx, long data) throws Http2Exception { Handler<Buffer> handler = pingHandler; if (handler != null) { Buffer buff = Buffer.buffer().appendLong(data); context.executeFromIO(v -> handler.handle(buff)); } }
@Override public void operationComplete(final ChannelFuture future) throws Exception { context.executeFromIO(v -> notifyHandler(future)); }
@Override public void onPingAckRead(ChannelHandlerContext ctx, long data) throws Http2Exception { Handler<AsyncResult<Buffer>> handler = pongHandlers.poll(); if (handler != null) { context.executeFromIO(v -> { Buffer buff = Buffer.buffer().appendLong(data); handler.handle(Future.succeededFuture(buff)); }); } }
private void handleException(Exception e) { handshaking = false; buffered.clear(); Handler<Throwable> handler = exceptionHandler(); if (handler != null) { context.executeFromIO(v -> { handler.handle(e); }); } else { log.error("Error in websocket handshake", e); } }
private void failed(ContextInternal context, Channel ch, Throwable th, Handler<AsyncResult<NetSocket>> connectHandler) { if (ch != null) { ch.close(); } context.executeFromIO(v -> doFailed(connectHandler, th)); }
@Override public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { C conn = getConnection(); context.executeFromIO(v -> conn.handleInterestedOpsChanged()); }
@Override public synchronized void onHeadersRead(ChannelHandlerContext ctx, int streamId, Http2Headers headers, int padding, boolean endOfStream) throws Http2Exception { Http2ClientStream stream = (Http2ClientStream) streams.get(streamId); if (stream != null) { context.executeFromIO(v -> { stream.handleHeaders(headers, null, endOfStream); }); } }
@Override public void onRstStreamRead(ChannelHandlerContext ctx, int streamId, long errorCode) { VertxHttp2Stream req; synchronized (this) { req = streams.get(streamId); if (req == null) { return; } } context.executeFromIO(v -> req.onResetRead(errorCode)); }
@Override public void channelInactive(ChannelHandlerContext chctx) throws Exception { super.channelInactive(chctx); if (connection != null) { ContextInternal ctx = connection.getContext(); ctx.executeFromIO(v -> connection.handleClosed()); if (removeHandler != null) { removeHandler.handle(connection); } } }
synchronized void onConnectionError(Throwable cause) { ArrayList<VertxHttp2Stream> copy; synchronized (this) { copy = new ArrayList<>(streams.values()); } for (VertxHttp2Stream stream : copy) { context.executeFromIO(v -> stream.handleException(cause)); } handleException(cause); }
@Override public void onUnknownFrame(ChannelHandlerContext ctx, byte frameType, int streamId, Http2Flags flags, ByteBuf payload) { VertxHttp2Stream req; synchronized (this) { req = streams.get(streamId); } if (req != null) { Buffer buff = Buffer.buffer(safeBuffer(payload, ctx.alloc())); context.executeFromIO(v -> req.handleCustomFrame(frameType, flags.value(), buff)); } }
@Override protected void onConnectionError(ChannelHandlerContext ctx, boolean outbound, Throwable cause, Http2Exception http2Ex) { connection.getContext().executeFromIO(v -> { connection.onConnectionError(cause); }); // Default behavior send go away super.onConnectionError(ctx, outbound, cause, http2Ex); }
void onStreamWritabilityChanged(Http2Stream s) { VertxHttp2Stream stream; synchronized (this) { stream = streams.get(s.id()); } if (stream != null) { context.executeFromIO(v -> stream.onWritabilityChanged()); } }
@Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt instanceof IdleStateEvent && ((IdleStateEvent) evt).state() == IdleState.ALL_IDLE) { context.executeFromIO(v -> conn.handleIdle()); } else { ctx.fireUserEventTriggered(evt); } } }
void onStreamClosed(Http2Stream stream) { VertxHttp2Stream removed; synchronized (this) { removed = streams.remove(stream.id()); if (removed == null) { return; } } context.executeFromIO(v -> removed.handleClose()); checkShutdownHandler(); }
@Override protected void onStreamError(ChannelHandlerContext ctx, boolean outbound, Throwable cause, Http2Exception.StreamException http2Ex) { connection.getContext().executeFromIO(v -> { connection.onStreamError(http2Ex.streamId(), http2Ex); }); // Default behavior reset stream super.onStreamError(ctx, outbound, cause, http2Ex); }