當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。