本文整理汇总了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);
}
示例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);
}
示例3: exceptionCaught
import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
示例4: exceptionCaught
import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
ctx.close();
logger.error("ctx close,cause:",cause);
}
示例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();
}
}
示例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();
}
示例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);
}
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例11: exceptionCaught
import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
cause.printStackTrace();
ctx.close();
}
示例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();
}
示例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;
}
}
示例14: exceptionCaught
import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
LOG.error("catch a exception ", cause);
ctx.close();
}
示例15: exceptionCaught
import io.netty.channel.ChannelHandlerContext; //导入方法依赖的package包/类
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}