当前位置: 首页>>代码示例>>Java>>正文


Java ChannelHandlerContext.close方法代码示例

本文整理汇总了Java中io.netty.channel.ChannelHandlerContext.close方法的典型用法代码示例。如果您正苦于以下问题:Java ChannelHandlerContext.close方法的具体用法?Java ChannelHandlerContext.close怎么用?Java ChannelHandlerContext.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.netty.channel.ChannelHandlerContext的用法示例。


在下文中一共展示了ChannelHandlerContext.close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPubAck

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
protected void onPubAck(ChannelHandlerContext ctx, MqttMessage msg) {
    if (!this.connected) {
        logger.debug("Protocol violation: Client {} must first sent a CONNECT message, now received PUBACK message, disconnect the client", this.clientId);
        ctx.close();
        return;
    }

    logger.debug("Message received: Received PUBACK message from client {} user {}", this.clientId, this.userName);

    MqttPacketIdVariableHeader variable = (MqttPacketIdVariableHeader) msg.variableHeader();
    int packetId = variable.packetId();

    // In the QoS 1 delivery protocol, the Sender
    // MUST treat the PUBLISH Packet as “unacknowledged” until it has received the corresponding
    // PUBACK packet from the receiver.
    logger.trace("Remove in-flight: Remove in-flight PUBLISH message {} for client {}", packetId, this.clientId);
    this.redis.removeInFlightMessage(this.clientId, packetId);
}
 
开发者ID:12315jack,项目名称:j1st-mqtt,代码行数:19,代码来源:SyncRedisHandler.java

示例2: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    ctx.close();

    Throwable error = translateException(cause);
    if (null != operation) {
        operation.caught(error);
        return;
    }

    // idle timeout.
    if (error instanceof FastdfsTimeoutException) {
        LOG.debug(error.getMessage(), error);
        return;
    }

    LOG.error(error.getMessage(), error);
}
 
开发者ID:rodbate,项目名称:fastdfs-spring-boot,代码行数:19,代码来源:FastdfsHandler.java

示例3: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    cause.printStackTrace();
    ctx.close();
}
 
开发者ID:intuit,项目名称:karate,代码行数:6,代码来源:FeatureServerHandler.java

示例4: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    ctx.close();
    logger.error("ctx close,cause:",cause);
}
 
开发者ID:all4you,项目名称:redant,代码行数:6,代码来源:PreHandleInterceptor.java

示例5: userEventTriggered

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt)
        throws Exception {

    if (LOGGER.isTraceEnabled()) {
        LOGGER.trace("userEventTriggered: {}", evt.getClass().getName());
    }

    // if the channel has been idle, close it
    if (evt == IdleStateEvent.FIRST_READER_IDLE_STATE_EVENT) {
        LOGGER.warn("No data received on channel, closing");
        ctx.close();
    }
}
 
开发者ID:smoketurner,项目名称:graphiak,代码行数:15,代码来源:AuthHandler.java

示例6: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    if (channel.isDiscoveryMode()) {
        loggerNet.debug("FrameCodec failed: ", cause);
    } else {
        if (cause instanceof IOException) {
            loggerNet.info("FrameCodec failed: " + ctx.channel().remoteAddress() + "(" + cause.getMessage() + ")");
            loggerNet.debug("FrameCodec failed: " + ctx.channel().remoteAddress(), cause);
        } else {
            loggerNet.error("FrameCodec failed: ", cause);
        }
    }
    ctx.close();
}
 
开发者ID:rsksmart,项目名称:rskj,代码行数:15,代码来源:FrameCodecHandler.java

示例7: decode

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) {
    if (in.readableBytes() < AbstractMessageDecoder.MESSAGE_LENGTH) {
        return;
    }

    in.markReaderIndex();
    int messageLength = in.readInt();

    if (messageLength < 0) {
        ctx.close();
    }

    if (in.readableBytes() < messageLength) {
        in.resetReaderIndex();
    } else {
        byte[] messageBody = new byte[messageLength];
        in.readBytes(messageBody);

        try {
            Object obj = util.decode(messageBody);
            out.add(obj);
        } catch (IOException ex) {
            Logger.getLogger(AbstractMessageDecoder.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:28,代码来源:AbstractMessageDecoder.java

示例8: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
  if(!ctx.channel().isOpen() || cause.getMessage().equals("Connection reset by peer")){
    logger.warn("Exception occurred with closed channel.  Connection: {}", connection.getName(), cause);
    return;
  }else{
    logger.error("Exception in RPC communication.  Connection: {}.  Closing connection.", connection.getName(), cause);
    ctx.close();
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:11,代码来源:RpcExceptionHandler.java

示例9: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    LOGGER.error("{} : exceptionCaught, message is {}", connectionInfo.toString(client), cause.getMessage());

    outboundChannel.close();
    ctx.close();
}
 
开发者ID:chhsiao90,项目名称:nitmproxy,代码行数:8,代码来源:TlsHandler.java

示例10: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext context, Throwable cause) {
    log.error("Exception inside channel handling pipeline.", cause);
    context.close();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:MessageDecoder.java

示例11: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
    cause.printStackTrace();
    ctx.close();
}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:6,代码来源:NettyClientMessageHandler.java

示例12: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    LOGGER.warn("Exception while handling request", cause);
    currentState = State.BAD_MESSAGE;
    ctx.close();
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:7,代码来源:AmqpDecoder.java

示例13: channelRead0

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void channelRead0(ChannelHandlerContext ctx, SocksRequest request) throws Exception {
    switch (request.protocolVersion()) {
        case SOCKS4a:
            log.warn("\tBad Handshake! (socks version not supported: 4)");
            ctx.write(new SocksInitResponse(SocksAuthScheme.UNKNOWN));
            if (ctx.channel().isActive()) {
                ctx.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
            }
            break;
        case SOCKS5:
            switch (request.requestType()) {
                case INIT:
                    ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
                    ctx.write(new SocksInitResponse(SocksAuthScheme.NO_AUTH));
                    break;
                case AUTH:
                    ctx.pipeline().addFirst(new SocksCmdRequestDecoder());
                    ctx.write(new SocksAuthResponse(SocksAuthStatus.SUCCESS));
                    break;
                case CMD:
                    switch (((SocksCmdRequest) request).cmdType()) {
                        case UDP:
                            // udp relay only supports IPv4 in this version
                            if (((SocksCmdRequest) request).addressType() != SocksAddressType.IPv4) {
                                ctx.write(new SocksCmdResponse(SocksCmdStatus.ADDRESS_NOT_SUPPORTED, ((SocksCmdRequest) request).addressType()));
                                log.warn("\tBad Handshake! (UDP request addr_type not support: {})", ((SocksCmdRequest) request).addressType());
                                ctx.close();
                                break;
                            }
                        case CONNECT:
                            ctx.pipeline().addLast(new XConnectHandler()); // handover
                            ctx.pipeline().remove(this);
                            ctx.fireChannelRead(request);
                            break;
                        default:
                            ctx.close();
                            log.warn("\tBad Handshake! (command not support: {})", ((SocksCmdRequest) request).cmdType());
                    }
                    break;
                case UNKNOWN:
                    log.warn("\tBad Handshake! (unknown request type: {})", request.requestType());
            }
            break;
        case UNKNOWN:
            log.warn("\tBad Handshake! (unknown protocol version: {}", request.protocolVersion());
            ctx.close();
            break;
    }
}
 
开发者ID:ZhangJiupeng,项目名称:AgentX,代码行数:51,代码来源:Socks5Handler.java

示例14: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
  LOG.error("catch a exception ", cause);
  ctx.close();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:5,代码来源:MatrixTransportServerHandler.java

示例15: exceptionCaught

import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
  cause.printStackTrace();
  ctx.close();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:6,代码来源:MatrixTransportClientHandler.java


注:本文中的io.netty.channel.ChannelHandlerContext.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。