• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ChannelState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.netty.channel.ChannelState的典型用法代码示例。如果您正苦于以下问题:Java ChannelState类的具体用法?Java ChannelState怎么用?Java ChannelState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChannelState类属于org.jboss.netty.channel包,在下文中一共展示了ChannelState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: handleServerChannel

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
private void handleServerChannel(ChannelEvent e) {
    IsdnServerChannel channel = (IsdnServerChannel) e.getChannel();
    ChannelFuture future = e.getFuture();
    if (e instanceof ChannelStateEvent) {
        ChannelStateEvent stateEvent = (ChannelStateEvent) e;
        ChannelState state = stateEvent.getState();
        Object value = stateEvent.getValue();
        switch (state) {
        case OPEN:
            if (Boolean.FALSE.equals(value)) {
                close(channel, future);
            }
            break;
        case BOUND:
            if (value != null) {
                bind(channel, future, (IsdnSocketAddress) value);
            } else {
                logger.warn("eventSunk() :: UNHANDLED (BOUND value=null) --> {}", e);
                close(channel, future);
            }
            break;
        default:
            logger.warn("eventSunk() :: UNHANDLED --> {}", e);
        }
    }
}
 
开发者ID:rmarins,项目名称:netty-isdn-transport,代码行数:27,代码来源:IsdnServerPipelineSink.java


示例2: multiple_connected_same_ip

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void multiple_connected_same_ip() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent openEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);

    verify(ctx, times(2)).sendUpstream(openEvent);
    verify(channel, times(1)).write(argThat(new ArgumentMatcher<Object>() {
        @Override
        public boolean matches(Object argument) {
            return QueryMessages.connectionsExceeded(MAX_CONNECTIONS_PER_IP).equals(argument);
        }
    }));
    verify(channelFuture, times(1)).addListener(ChannelFutureListener.CLOSE);
    verify(whoisLog).logQueryResult(anyString(), eq(0), eq(0), eq(QueryCompletionInfo.REJECTED), eq(0L), (InetAddress) Mockito.anyObject(), Mockito.anyInt(), eq(""));
    verify(ctx, times(2)).sendUpstream(openEvent);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:22,代码来源:ConnectionPerIpLimitHandlerTest.java


示例3: multiple_connected_limit_disabled

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void multiple_connected_limit_disabled() throws Exception {
    subject.setMaxConnectionsPerIp(0);

    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent openEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);

    final ChannelEvent closeEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.FALSE);
    subject.handleUpstream(ctx, closeEvent);
    subject.handleUpstream(ctx, closeEvent);
    subject.handleUpstream(ctx, closeEvent);

    verify(ctx, times(3)).sendUpstream(openEvent);
    verify(ctx, times(3)).sendUpstream(closeEvent);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:24,代码来源:ConnectionPerIpLimitHandlerTest.java


示例4: multiple_connected_unlimited_allowed

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void multiple_connected_unlimited_allowed() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);

    when(ipResourceConfiguration.isUnlimitedConnections(any(IpInterval.class))).thenReturn(true);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent event = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);

    verify(ctx, times(3)).sendUpstream(event);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:18,代码来源:ConnectionPerIpLimitHandlerTest.java


示例5: multiple_connected_proxy_allowed

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void multiple_connected_proxy_allowed() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);

    when(ipResourceConfiguration.isProxy(any(IpInterval.class))).thenReturn(true);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent event = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);

    verify(ctx, times(3)).sendUpstream(event);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:18,代码来源:ConnectionPerIpLimitHandlerTest.java


示例6: multiple_connected_different_ip

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void multiple_connected_different_ip() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    final InetSocketAddress remoteAddress2 = new InetSocketAddress("10.0.0.1", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress).thenReturn(remoteAddress).thenReturn(remoteAddress2);

    final ChannelEvent event = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event);
    subject.handleUpstream(ctx, event);

    final ChannelEvent event2 = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, event2);

    verify(ctx, times(2)).sendUpstream(event);
    verify(ctx, times(1)).sendUpstream(event2);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:20,代码来源:ConnectionPerIpLimitHandlerTest.java


示例7: multiple_connected_same_ip_and_closed

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void multiple_connected_same_ip_and_closed() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress("10.0.0.0", 43);
    when(channel.getRemoteAddress()).thenReturn(remoteAddress);

    final ChannelEvent openEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.TRUE);
    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);

    final ChannelEvent closeEvent = new UpstreamChannelStateEvent(channel, ChannelState.OPEN, Boolean.FALSE);
    subject.handleUpstream(ctx, closeEvent);
    subject.handleUpstream(ctx, closeEvent);

    subject.handleUpstream(ctx, openEvent);
    subject.handleUpstream(ctx, openEvent);

    verify(ctx, times(4)).sendUpstream(openEvent);
    verify(ctx, times(2)).sendUpstream(closeEvent);
    verify(channel, never()).close();
    verify(channel, never()).write(anyObject());
    verify(channelFuture, never()).addListener(ChannelFutureListener.CLOSE);
}
 
开发者ID:RIPE-NCC,项目名称:whois,代码行数:23,代码来源:ConnectionPerIpLimitHandlerTest.java


示例8: handleUpstream

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent event) throws Exception {
    if (event instanceof MessageEvent) {
        MessageEvent msgEvent = (MessageEvent) event;
        Object msg = msgEvent.getMessage();
        if (msg instanceof ChannelBuffer) {
            callDecode(ctx, (ChannelBuffer) msg, msgEvent.getRemoteAddress());
            return;
        }
    } else if (event instanceof ChannelStateEvent) {
        ChannelStateEvent stateEvent = (ChannelStateEvent) event;
        if (stateEvent.getState() == ChannelState.CONNECTED) {
            if (stateEvent.getValue() != null) {
                lengthBytesToRead = lengthFieldLength;
                lengthBuffer = getBuffer(ctx.getChannel().getConfig().getBufferFactory(),
                        lengthBytesToRead);
            }
        }
    }
    ctx.sendUpstream(event);
}
 
开发者ID:mnip91,项目名称:proactive-component-monitoring,代码行数:21,代码来源:PNPClientFrameDecoder.java


示例9: shouldThrowExceptionIfBadHandshakeIsReceived

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void shouldThrowExceptionIfBadHandshakeIsReceived() throws Exception {
    final InetSocketAddress remoteAddress = new InetSocketAddress(0);

    // start off by simulating a 'channelConnected' event
    // this should set the internal state properly
    handler.channelConnected(ctx, new UpstreamChannelStateEvent(channel, ChannelState.CONNECTED, remoteAddress));

    // we shouldn't forward the event on
    Mockito.verifyNoMoreInteractions(ctx);

    // now simulate an incoming message
    // the handler is expecting a handshake message
    // but we're going to feed it something else, and we expect an exception as a result
    ChannelBuffer badHandshakeBuffer = ChannelBuffers.wrappedBuffer(new byte[]{0, 1, 3, 4});
    expectedException.expect(IOException.class);
    handler.messageReceived(ctx, new UpstreamMessageEvent(channel, badHandshakeBuffer, remoteAddress));
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:19,代码来源:IncomingHandshakeHandlerTest.java


示例10: shouldResolveAddressAndForwardEventWhenConnectIsCalledWithAnUnresolvedInetSocketAddress

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void shouldResolveAddressAndForwardEventWhenConnectIsCalledWithAnUnresolvedInetSocketAddress() throws Exception {
    DefaultChannelFuture originalEventFuture = new DefaultChannelFuture(channel, false);
    ChannelStateEvent event = new DownstreamChannelStateEvent(
            channel,
            originalEventFuture,
            ChannelState.CONNECTED,
            createUnresolvedRemoteAddress()
    );

    handler.connectRequested(ctx, event);

    ArgumentCaptor<DownstreamChannelStateEvent> eventCaptor = ArgumentCaptor.forClass(DownstreamChannelStateEvent.class);
    verify(ctx).sendDownstream(eventCaptor.capture());

    DownstreamChannelStateEvent forwardedEvent = eventCaptor.getValue();
    assertThat(forwardedEvent.getChannel(), equalTo(channel));
    assertThat(forwardedEvent.getState(), equalTo(ChannelState.CONNECTED));
    assertThat(forwardedEvent.getFuture(), Matchers.<ChannelFuture>equalTo(originalEventFuture));

    InetSocketAddress forwardedAddress = (InetSocketAddress) forwardedEvent.getValue();
    assertThat(forwardedAddress.isUnresolved(), equalTo(false));
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:24,代码来源:AddressResolverHandlerTest.java


示例11: shouldFireExceptionIfConnectEventCannotBeForwarded

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void shouldFireExceptionIfConnectEventCannotBeForwarded() throws Exception {
    setupPipelineToRunFireEventLaterInline();

    // setup the ctx to throw an exception when we attempt to send the connected event downstream
    IllegalStateException resolveFailureCause = new IllegalStateException("downstream event failed");
    doThrow(resolveFailureCause).when(ctx).sendDownstream(any(DownstreamChannelStateEvent.class));

    // initiate the connect request
    DefaultChannelFuture originalEventFuture = new DefaultChannelFuture(channel, false);
    ChannelStateEvent event = new DownstreamChannelStateEvent(
            channel,
            originalEventFuture,
            ChannelState.CONNECTED,
            createUnresolvedRemoteAddress()
    );

    handler.connectRequested(ctx, event);

    // firing the connect downstream should cause a "fireExceptionCaughtLater" call
    ArgumentCaptor<DefaultExceptionEvent> exceptionEventCaptor = ArgumentCaptor.forClass(DefaultExceptionEvent.class);
    verify(ctx).sendUpstream(exceptionEventCaptor.capture());

    DefaultExceptionEvent exceptionEvent = exceptionEventCaptor.getValue();
    assertThat(exceptionEvent.getCause(), Matchers.<Throwable>is(resolveFailureCause));
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:27,代码来源:AddressResolverHandlerTest.java


示例12: shouldPassOnProxyConnectRequestedEvent

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void shouldPassOnProxyConnectRequestedEvent() throws Exception {
    ChannelFuture originalConnectFuture = Channels.future(channel);
    InetSocketAddress originalValue = new InetSocketAddress(0);

    // initiate the connect request
    handler.connectRequested(ctx, new DownstreamChannelStateEvent(channel, originalConnectFuture, ChannelState.CONNECTED, originalValue));

    // verify that a proxy event is sent instead of the original event
    ArgumentCaptor<DownstreamChannelStateEvent> downstreamEvent = ArgumentCaptor.forClass(DownstreamChannelStateEvent.class);
    verify(ctx, atLeastOnce()).getChannel();
    verify(ctx).sendDownstream(downstreamEvent.capture());
    verifyNoMoreInteractions(ctx);

    DownstreamChannelStateEvent forwardedEvent = downstreamEvent.getValue();
    assertThat(forwardedEvent.getChannel(), is(channel));
    assertThat(forwardedEvent.getFuture(), notNullValue());
    assertThat(forwardedEvent.getFuture(), not(originalConnectFuture));
    assertThat(forwardedEvent.getState(), is(ChannelState.CONNECTED));
    assertThat((InetSocketAddress) forwardedEvent.getValue(), is(originalValue));
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:22,代码来源:OutgoingHandshakeHandlerTest.java


示例13: shouldFailOriginalConnectFutureWhenProxyConnectFutureIsMarkedAsFailed

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void shouldFailOriginalConnectFutureWhenProxyConnectFutureIsMarkedAsFailed() throws Exception {
    ChannelFuture originalConnectFuture = Channels.future(channel);
    InetSocketAddress originalValue = new InetSocketAddress(0);

    // initiate the connect request
    handler.connectRequested(ctx, new DownstreamChannelStateEvent(channel, originalConnectFuture, ChannelState.CONNECTED, originalValue));

    // get the proxy event
    ArgumentCaptor<DownstreamChannelStateEvent> downstreamEvent = ArgumentCaptor.forClass(DownstreamChannelStateEvent.class);
    verify(ctx, atLeastOnce()).getChannel();
    verify(ctx).sendDownstream(downstreamEvent.capture());
    verifyNoMoreInteractions(ctx);

    // mark the proxy event future as having failed
    DownstreamChannelStateEvent forwardedEvent = downstreamEvent.getValue();

    Exception failureCause = new Exception();
    forwardedEvent.getFuture().setFailure(failureCause);

    // and check that we've triggered the original future as well
    assertThat(originalConnectFuture.isDone(), equalTo(true));
    assertThat(originalConnectFuture.isSuccess(), equalTo(false));
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:25,代码来源:OutgoingHandshakeHandlerTest.java


示例14: shouldNotTriggerOriginalConnectFutureIfProxyConnectFutureSucceeds

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void shouldNotTriggerOriginalConnectFutureIfProxyConnectFutureSucceeds() throws Exception {
    ChannelFuture originalConnectFuture = Channels.future(channel);
    InetSocketAddress originalValue = new InetSocketAddress(0);

    // initiate the connect request
    handler.connectRequested(ctx, new DownstreamChannelStateEvent(channel, originalConnectFuture, ChannelState.CONNECTED, originalValue));

    // get the proxy event
    ArgumentCaptor<DownstreamChannelStateEvent> downstreamEvent = ArgumentCaptor.forClass(DownstreamChannelStateEvent.class);
    verify(ctx, atLeastOnce()).getChannel();
    verify(ctx).sendDownstream(downstreamEvent.capture());

    // mark the proxy event future as having succeeded
    DownstreamChannelStateEvent forwardedEvent = downstreamEvent.getValue();
    forwardedEvent.getFuture().setSuccess();

    // and check that original future _is not triggered_ and no events are forwarded!
    assertThat(originalConnectFuture.isDone(), equalTo(false));
    verifyNoMoreInteractions(ctx);
}
 
开发者ID:allengeorge,项目名称:libraft,代码行数:22,代码来源:OutgoingHandshakeHandlerTest.java


示例15: handleUpstream

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
/**
 * <p>
 * {@inheritDoc}
 * </p>
 * <p>
 * Overriden to log ChannelStateEvents if they have a state other than
 * {@link ChannelState#INTEREST_OPS}, i. e. OPEN, BOUND, CONNECTED.
 * </p>
 * 
 * @param ctx
 *            the context object for this handler
 * @param e
 *            the upstream event to process or intercept
 */
@Override
public void handleUpstream(final ChannelHandlerContext ctx, final ChannelEvent e) throws Exception {
	if (e instanceof ChannelStateEvent) {
		ChannelStateEvent stateEvent = (ChannelStateEvent) e;
		if (stateEvent.getState() != ChannelState.INTEREST_OPS) {
			log.info(e.toString());
			if (stateEvent.getState() == ChannelState.CONNECTED && stateEvent.getValue() == null) {
				// Remove channel from container when client disconnects
				channelContainer.removeChannel(e.getChannel());
			}
		}

	}
	super.handleUpstream(ctx, e);
}
 
开发者ID:mgm-tp,项目名称:perfload-core,代码行数:30,代码来源:ServerHandler.java


示例16: testDisconnect

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void testDisconnect() {
	emulateConnectAndOpen();

	channel.write(NettyTestUtils.createData(1234L));
	assertEquals(1, sink.events.size());
	checkIsSendDataRequestWithData(sink.events.poll(),
			NettyTestUtils.createData(1234L));

	channel.disconnect();
	Channels.fireMessageReceived(channel,
			HttpTunnelMessageUtils.createSendDataResponse());
	assertEquals(1, sink.events.size());

	HttpRequest request = NettyTestUtils.checkIsDownstreamMessageEvent(
			sink.events.poll(), HttpRequest.class);
	assertTrue(HttpTunnelMessageUtils.isCloseTunnelRequest(request, USER_AGENT));
	assertEquals("newTunnel",
			HttpTunnelMessageUtils.extractTunnelId(request));
	Channels.fireMessageReceived(channel,
			HttpTunnelMessageUtils.createTunnelCloseResponse());
	assertEquals(1, sink.events.size());
	NettyTestUtils.checkIsStateEvent(sink.events.poll(),
			ChannelState.CONNECTED, null);
}
 
开发者ID:reines,项目名称:httptunnel,代码行数:26,代码来源:HttpTunnelClientSendHandlerTest.java


示例17: testClose

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void testClose() {
	emulateConnectAndOpen();

	channel.close();
	assertEquals(1, sink.events.size());
	HttpRequest request = NettyTestUtils.checkIsDownstreamMessageEvent(
			sink.events.poll(), HttpRequest.class);
	assertTrue(HttpTunnelMessageUtils.isCloseTunnelRequest(request, USER_AGENT));
	assertEquals("newTunnel",
			HttpTunnelMessageUtils.extractTunnelId(request));
	Channels.fireMessageReceived(channel,
			HttpTunnelMessageUtils.createTunnelCloseResponse());
	assertEquals(1, sink.events.size());
	NettyTestUtils.checkIsStateEvent(sink.events.poll(), ChannelState.OPEN,
			false);
}
 
开发者ID:reines,项目名称:httptunnel,代码行数:18,代码来源:HttpTunnelClientSendHandlerTest.java


示例18: testBind_preResolvedAddress_ipv6

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Test
public void testBind_preResolvedAddress_ipv6() {
	ChannelFuture bindFuture = Channels.bind(channel,
			RESOLVED_LOCAL_ADDRESS_IPV6);
	assertFalse(bindFuture.isDone());

	assertEquals(1, sendSink.events.size());
	assertEquals(1, pollSink.events.size());

	ChannelEvent sendChannelEvent = sendSink.events.poll();
	NettyTestUtils.checkIsStateEvent(sendChannelEvent, ChannelState.BOUND,
			RESOLVED_LOCAL_ADDRESS_IPV6);
	ChannelEvent pollChannelEvent = pollSink.events.poll();
	NettyTestUtils.checkIsStateEvent(pollChannelEvent, ChannelState.BOUND,
			RESOLVED_LOCAL_ADDRESS_IPV6_EPHEMERAL_PORT);

	sendChannel.emulateBound(RESOLVED_LOCAL_ADDRESS_IPV6,
			sendChannelEvent.getFuture());
	assertFalse(bindFuture.isDone());
	pollChannel.emulateBound(RESOLVED_LOCAL_ADDRESS_IPV4_SELECTED_PORT,
			pollChannelEvent.getFuture());
	assertTrue(bindFuture.isDone());
	assertTrue(bindFuture.isSuccess());

	assertEquals(channel.getLocalAddress(), RESOLVED_LOCAL_ADDRESS_IPV6);
}
 
开发者ID:reines,项目名称:httptunnel,代码行数:27,代码来源:HttpTunnelClientChannelTest.java


示例19: handleUpstream

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
@Override
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
    if(e instanceof ChannelStateEvent && ((ChannelStateEvent) e).getState() != ChannelState.INTEREST_OPS) {
        LOG.debug(e.toString());
    }
    super.handleUpstream(ctx, e);
}
 
开发者ID:ShifuML,项目名称:guagua,代码行数:8,代码来源:NettyMasterCoordinator.java


示例20: eventSunk

import org.jboss.netty.channel.ChannelState; //导入依赖的package包/类
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) throws Exception {

        IsdnClientChannel channel = (IsdnClientChannel) e.getChannel();
        ChannelFuture future = e.getFuture();
        if (e instanceof ChannelStateEvent) {
            ChannelStateEvent stateEvent = (ChannelStateEvent) e;
            ChannelState state = stateEvent.getState();
            Object value = stateEvent.getValue();
            switch (state) {
            case OPEN:
                if (FALSE.equals(value)) {
                    IsdnWorker.close(channel, future);
                }
                break;
            case BOUND:
                if (value != null) {
                    bind(channel, future, (IsdnSocketAddress) value);
                } else {
                    IsdnWorker.close(channel, future);
                }
                break;
            case CONNECTED:
                if (value != null) {
                    connect(channel, future, (IsdnSocketAddress) value);
                } else {
                    IsdnWorker.close(channel, future);
                }
                break;
            case INTEREST_OPS:
                IsdnWorker.setInterestOps(channel, future, ((Integer) value).intValue());
                break;
            }
        } else if (e instanceof MessageEvent) {
            IsdnWorker.write(channel, future, ((MessageEvent) e).getMessage());
        }

    }
 
开发者ID:rmarins,项目名称:netty-isdn-transport,代码行数:38,代码来源:IsdnClientPipelineSink.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StructEntry类代码示例发布时间:2022-05-22
下一篇:
Java ColumnOverride类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap