io.netty.channel.ChannelHandlerContext#disconnect ( )源码实例Demo

下面列出了io.netty.channel.ChannelHandlerContext#disconnect ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: onos   文件: LispChannelHandler.java
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
        throws Exception {

    if (evt instanceof IdleStateEvent) {
        IdleStateEvent event = (IdleStateEvent) evt;
        if (event.state() == IdleState.READER_IDLE) {
            log.info("READER_IDLE read timeout");
            ctx.disconnect();
        } else if (event.state() == IdleState.WRITER_IDLE) {
            log.info("WRITER_IDLE write timeout");
            ctx.disconnect();
        } else if (event.state() == IdleState.ALL_IDLE) {
            log.info("ALL_IDLE total timeout");
            ctx.disconnect();
        }
    }
}
 
源代码2 项目: web3sdk   文件: ChannelHandler.java
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    // logger.error("network error ", cause);
    // lost the connection,get ip info
    String host = ((SocketChannel) ctx.channel()).remoteAddress().getAddress().getHostAddress();
    Integer port = ((SocketChannel) ctx.channel()).remoteAddress().getPort();

    logger.debug(
            " exceptionCaught, disconnect "
                    + host
                    + ":"
                    + String.valueOf(port)
                    + " ,"
                    + String.valueOf(ctx.channel().isActive()));

    ctx.disconnect();
    ctx.close();
}
 
源代码3 项目: netty-4.1.22   文件: LoggingHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
    if (logger.isEnabled(internalLevel)) {
        logger.log(internalLevel, format(ctx, "DISCONNECT"));
    }
    ctx.disconnect(promise);
}
 
源代码4 项目: netty-4.1.22   文件: SslHandler.java
private void closeOutboundAndChannel(
        final ChannelHandlerContext ctx, final ChannelPromise promise, boolean disconnect) throws Exception {
    if (!ctx.channel().isActive()) {
        if (disconnect) {
            ctx.disconnect(promise);
        } else {
            ctx.close(promise);
        }
        return;
    }

    outboundClosed = true;
    engine.closeOutbound();

    ChannelPromise closeNotifyPromise = ctx.newPromise();
    try {
        flush(ctx, closeNotifyPromise);
    } finally {
        // It's important that we do not pass the original ChannelPromise to safeClose(...) as when flush(....)
        // throws an Exception it will be propagated to the AbstractChannelHandlerContext which will try
        // to fail the promise because of this. This will then fail as it was already completed by safeClose(...).
        // We create a new ChannelPromise and try to notify the original ChannelPromise
        // once it is complete. If we fail to do so we just ignore it as in this case it was failed already
        // because of a propagated Exception.
        //
        // See https://github.com/netty/netty/issues/5931
        safeClose(ctx, closeNotifyPromise, ctx.newPromise().addListener(
                new ChannelPromiseNotifier(false, promise)));
    }
}
 
源代码5 项目: netty.book.kor   文件: LoggingHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
    if (logger.isEnabled(internalLevel)) {
        logger.log(internalLevel, format(ctx, "DISCONNECT"));
    }
    ctx.disconnect(promise);
}
 
源代码6 项目: netty-http2   文件: HttpConnectionHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
    // HTTP/2 connection requirements:
    //
    // When either endpoint closes the transport-level connection,
    // it must first send a GOAWAY frame.
    //
    // Avoid NotYetConnectedException
    if (!ctx.channel().isActive()) {
        ctx.disconnect(promise);
    } else {
        sendGoAwayFrame(ctx, promise);
    }
}
 
源代码7 项目: grpc-nebula-java   文件: TsiFrameHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) {
  ctx.disconnect(promise);
}
 
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
    ctx.disconnect(promise);
}
 
源代码9 项目: couchbase-jvm-core   文件: KeyValueAuthHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
    ctx.disconnect(promise);
}
 
源代码10 项目: bazel   文件: AbstractHttpHandler.java
@SuppressWarnings("FutureReturnValueIgnored")
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) {
  failAndResetUserPromise(new ClosedChannelException());
  ctx.disconnect(promise);
}
 
源代码11 项目: riiablo   文件: ReliableChannelHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
  Gdx.app.debug(TAG, "disconnect");
  ctx.disconnect(promise);
}
 
源代码12 项目: riiablo   文件: EndpointedChannelHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
  if (DEBUG_CALLS) Gdx.app.debug(TAG, "disconnect");
  ctx.disconnect(promise);
}
 
源代码13 项目: netty-4.1.22   文件: FlushConsolidationHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
    // Try to flush one last time if flushes are pending before disconnect the channel.
    resetReadAndFlushIfNeeded(ctx);
    ctx.disconnect(promise);
}
 
源代码14 项目: netty-http-server   文件: FilterLogginglHandler.java
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) {
    ctx.disconnect(promise);
}
 
源代码15 项目: Ak47   文件: NettyChannelHandlerAdapter.java
@Override
public void disconnect(ChannelHandlerContext nettyctx, ChannelPromise promise)
        throws Exception {
    nettyctx.disconnect(promise);
}
 
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
  ctx.disconnect(promise);
}
 
源代码17 项目: netty4.0.27Learn   文件: SpdyFrameCodec.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
    ctx.disconnect(promise);
}
 
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
    ctx.disconnect(promise);
}
 
源代码19 项目: riiablo   文件: ReliableChannelHandler.java
@Override
public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
  Gdx.app.debug(TAG, "disconnect");
  ctx.disconnect(promise);
}
 
源代码20 项目: azure-cosmosdb-java   文件: RntbdRequestManager.java
/**
 * Called once a disconnect operation is made.
 *
 * @param context the {@link ChannelHandlerContext} for which the disconnect operation is made
 * @param promise the {@link ChannelPromise} to notify once the operation completes
 */
@Override
public void disconnect(final ChannelHandlerContext context, final ChannelPromise promise) {
    this.traceOperation(context, "disconnect");
    context.disconnect(promise);
}