Java Code Examples for io.netty.channel.Channel#disconnect()
The following examples show how to use
io.netty.channel.Channel#disconnect() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HttpServerHandler.java From SI with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { Channel channel = ctx.channel(); log.debug("channelUnregistered={}", channel); /* * else { InetSocketAddress address = (InetSocketAddress) channel.remoteAddress(); String addr = * address.getHostName(); * * if (logger.isErrorEnabled()) { if (addr.equalsIgnoreCase("10.101.101.98") == false) * logger.error("channelUnregistered=ctx.attr(LISTENER_ATTR_KEY) Not Found." ); } } */ if (requestListener != null) { requestListener.channelDisconnected(ctx); } channel.disconnect(); }
Example 2
Source File: GetJobsAction.java From spinach with Apache License 2.0 | 6 votes |
/** * Disconnect the channel. Why {@link Channel#disconnect()} and not {@link DisqueCommands#quit()}? The quit command produces * an {@code OK} result which is read by the channel. Sometimes the pipeline is not finished with reading but the disconnect * is already initiated and this raises an {@link java.io.IOException}. * * The {@link Channel} is retrieved by reflection because it is not exposed. * * @param redisChannelHandler the channel handler. */ private void disconnect(RedisChannelHandler<?, ?> redisChannelHandler) { RedisChannelHandler<?, ?> rch = redisChannelHandler; RedisChannelWriter<?, ?> channelWriter = rch.getChannelWriter(); try { Field field = CommandHandler.class.getDeclaredField("channel"); field.setAccessible(true); Channel o = (Channel) field.get(channelWriter); if (o != null && o.isOpen()) { o.disconnect(); } } catch (Exception e) { throw new IllegalStateException("Cannot look up/retrieve the channel from the " + CommandHandler.class.getName()); } }
Example 3
Source File: HttpServerHandler.java From SI with BSD 2-Clause "Simplified" License | 6 votes |
@Override public void channelUnregistered(ChannelHandlerContext ctx) throws Exception { Channel channel = ctx.channel(); log.debug("channelUnregistered={}", channel); /* * else { InetSocketAddress address = (InetSocketAddress) channel.remoteAddress(); String addr = * address.getHostName(); * * if (logger.isErrorEnabled()) { if (addr.equalsIgnoreCase("10.101.101.98") == false) * logger.error("channelUnregistered=ctx.attr(LISTENER_ATTR_KEY) Not Found." ); } } */ if (requestListener != null) { requestListener.channelDisconnected(ctx); } channel.disconnect(); }
Example 4
Source File: WebSocketTextFrameHandler.java From hivemq-community-edition with Apache License 2.0 | 5 votes |
@Override protected void channelRead0(final ChannelHandlerContext ctx, final TextWebSocketFrame msg) throws Exception { final Channel channel = ctx.channel(); channel.disconnect(); if (log.isDebugEnabled()) { log.debug("Sending websocket text frames is illegal, only binary frames are allowed for MQTT over websockets. " + "Disconnecting client with IP{}.", ChannelUtils.getChannelIP(channel)); } }
Example 5
Source File: TcpRepository.java From ClusterDeviceControlPlatform with MIT License | 5 votes |
/** * 手动移除相应的 Channel * * @param channel 欲被手动移除的 Channel */ private void manualRemoveChannel(Channel channel) { if (channel.isActive()) { channel.disconnect(); } removeChannelCompleted(channel); }
Example 6
Source File: TcpRepository.java From ClusterDeviceControlPlatform with MIT License | 5 votes |
/** * 服务器优雅关闭时,关闭所有的已激活 Channel */ public void removeAllChannel() { for (int i = 1; i < CHANNEL_ARRAY.length(); i++) { Channel channel = CHANNEL_ARRAY.get(i); if (channel != null && channel.isActive()) { channel.disconnect(); } } }
Example 7
Source File: ReconnectOnCloseListener.java From jreactive-8583 with Apache License 2.0 | 5 votes |
@Override public void operationComplete(ChannelFuture future) { final Channel channel = future.channel(); logger.debug("Client connection was closed to {}", channel.remoteAddress()); channel.disconnect(); scheduleReconnect(); }
Example 8
Source File: OvsdbConnectionService.java From ovsdb with Eclipse Public License 1.0 | 5 votes |
@Override public void disconnect(final OvsdbClient client) { if (client == null) { return; } Channel channel = CONNECTIONS.get(client); if (channel != null) { //It's an explicit disconnect from user, so no need to notify back //to user about the disconnect. client.setConnectionPublished(false); channel.disconnect(); } CONNECTIONS.remove(client); }