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


Java ChannelStateEvent.getValue方法代码示例

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


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

示例1: handleUpstream

import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@Override
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e)
		throws Exception {
	if (e instanceof ChannelStateEvent) {
		ChannelStateEvent evt = (ChannelStateEvent) e;
		switch (evt.getState()) {
		case OPEN:
		case BOUND:
			// Special case: OPEND and BOUND events are before CONNECTED,
			// but CLOSED and UNBOUND events are after DISCONNECTED: should
			// those events be blocked too?
			if (isBlocked(ctx) && !continues(ctx, evt)) {
				// don't pass to next level since channel was blocked early
				return;
			} else {
				ctx.sendUpstream(e);
				return;
			}
		case CONNECTED:
			if (evt.getValue() != null) {
				// CONNECTED
				InetSocketAddress inetSocketAddress = (InetSocketAddress) e
						.getChannel().getRemoteAddress();
				if (!accept(ctx, e, inetSocketAddress)) {
					ctx.setAttachment(Boolean.TRUE);
					
					final ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
					
					buffer.writeBytes("/".getBytes());
					buffer.writeBytes("ok".getBytes());
					
					ChannelFuture future = e.getChannel().write(buffer);
					future.addListener(ChannelFutureListener.CLOSE);
					LOG.info("Ignoring " + inetSocketAddress.getAddress().getHostAddress());
					
					if (isBlocked(ctx) && !continues(ctx, evt)) {
						// don't pass to next level since channel was
						// blocked early
						return;
					}
				}
				// This channel is not blocked
				ctx.setAttachment(null);
			} else {
				// DISCONNECTED
				if (isBlocked(ctx) && !continues(ctx, evt)) {
					// don't pass to next level since channel was blocked
					// early
					return;
				}
			}
			break;
		}
	}
	if (isBlocked(ctx) && !continues(ctx, e)) {
		// don't pass to next level since channel was blocked early
		return;
	}
	// Whatever it is, if not blocked, goes to the next level
	ctx.sendUpstream(e);
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:62,代码来源:IpFilterHandler.java

示例2: handleDownstream

import org.jboss.netty.channel.ChannelStateEvent; //导入方法依赖的package包/类
@Override
public void handleDownstream(ChannelHandlerContext ctx, ChannelEvent e)
           throws Exception {

	
	logger.debug("handleDownstream e={}", e);
	
	
       if (e instanceof MessageEvent) {
       	logger.debug("MessageEvent >> writeRequested");
           writeRequested(ctx, (MessageEvent) e);
       } else if (e instanceof ChannelStateEvent) {
           ChannelStateEvent evt = (ChannelStateEvent) e;
           switch (evt.getState()) {
           case OPEN:
               if (!Boolean.TRUE.equals(evt.getValue())) {
               	logger.debug("ChannelStateEvent >> closeRequested");
                   closeRequested(ctx, evt);
               }
               break;
           case BOUND:
               if (evt.getValue() != null) {
               	logger.debug("ChannelStateEvent >> bindRequested");
                   bindRequested(ctx, evt);
               } else {
               	logger.debug("ChannelStateEvent >> unbindRequested");
                   unbindRequested(ctx, evt);
               }
               break;
           case CONNECTED:
               if (evt.getValue() != null) {
               	logger.debug("ChannelStateEvent >> connectRequested");
                   connectRequested(ctx, evt);
               } else {
               	logger.debug("ChannelStateEvent >> disconnectRequested");
                   disconnectRequested(ctx, evt);
               }
               break;
           case INTEREST_OPS:
           	logger.debug("ChannelStateEvent >> setInterestOpsRequested");
               setInterestOpsRequested(ctx, evt);
               break;
           default:
           	logger.debug("ChannelStateEvent >> sendDownstream");
               ctx.sendDownstream(e);
           }
       } else {
       	logger.debug("------ >> sendDownstream");
           ctx.sendDownstream(e);
       }
   }
 
开发者ID:gncloud,项目名称:fastcatsearch3,代码行数:52,代码来源:CheckPointHandler.java


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