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

Java LocalServerChannel类代码示例

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

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



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

示例1: addLocalEndpoint

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
/**
 * Adds a channel that listens locally
 */
public SocketAddress addLocalEndpoint()
{
    ChannelFuture channelfuture;

    synchronized (this.endpoints)
    {
        channelfuture = ((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(LocalServerChannel.class)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                networkmanager.setNetHandler(new NetHandlerHandshakeMemory(NetworkSystem.this.mcServer, networkmanager));
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
            }
        }).group((EventLoopGroup)eventLoops.getValue()).localAddress(LocalAddress.ANY)).bind().syncUninterruptibly();
        this.endpoints.add(channelfuture);
    }

    return channelfuture.channel().localAddress();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:25,代码来源:NetworkSystem.java


示例2: addLocalEndpoint

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
/**
 * Adds a channel that listens locally
 */
public SocketAddress addLocalEndpoint()
{
    ChannelFuture channelfuture;

    synchronized (this.endpoints)
    {
        channelfuture = ((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(LocalServerChannel.class)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                networkmanager.setNetHandler(new NetHandlerHandshakeMemory(NetworkSystem.this.mcServer, networkmanager));
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
            }
        }).group((EventLoopGroup)SERVER_NIO_EVENTLOOP.getValue()).localAddress(LocalAddress.ANY)).bind().syncUninterruptibly();
        this.endpoints.add(channelfuture);
    }

    return channelfuture.channel().localAddress();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:25,代码来源:NetworkSystem.java


示例3: addLocalEndpoint

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
/**
 * Adds a channel that listens locally
 */
@SideOnly(Side.CLIENT)
public SocketAddress addLocalEndpoint()
{
    ChannelFuture channelfuture;

    synchronized (this.endpoints)
    {
        channelfuture = ((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(LocalServerChannel.class)).childHandler(new ChannelInitializer<Channel>()
        {
            protected void initChannel(Channel p_initChannel_1_) throws Exception
            {
                NetworkManager networkmanager = new NetworkManager(EnumPacketDirection.SERVERBOUND);
                networkmanager.setNetHandler(new NetHandlerHandshakeMemory(NetworkSystem.this.mcServer, networkmanager));
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast((String)"packet_handler", (ChannelHandler)networkmanager);
            }
        }).group((EventLoopGroup)SERVER_NIO_EVENTLOOP.getValue()).localAddress(LocalAddress.ANY)).bind().syncUninterruptibly();
        this.endpoints.add(channelfuture);
    }

    return channelfuture.channel().localAddress();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:NetworkSystem.java


示例4: setUpServer

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
/**
 * Sets up a server channel bound to the given local address.
 *
 * @return the event loop group used to process incoming connections.
 */
static EventLoopGroup setUpServer(
    ChannelInitializer<LocalChannel> serverInitializer, LocalAddress localAddress)
    throws Exception {
  // Only use one thread in the event loop group. The same event loop group will be used to
  // register client channels during setUpClient as well. This ensures that all I/O activities
  // in both channels happen in the same thread, making debugging easier (i. e. no need to jump
  // between threads when debugging, everything happens synchronously within the only I/O
  // effectively). Note that the main thread is still separate from the I/O thread and
  // synchronization (using the lock field) is still needed when the main thread needs to verify
  // properties calculated by the I/O thread.
  EventLoopGroup eventLoopGroup = new NioEventLoopGroup(1);
  ServerBootstrap sb =
      new ServerBootstrap()
          .group(eventLoopGroup)
          .channel(LocalServerChannel.class)
          .childHandler(serverInitializer);
  ChannelFuture unusedFuture = sb.bind(localAddress).syncUninterruptibly();
  return eventLoopGroup;
}
 
开发者ID:google,项目名称:nomulus,代码行数:25,代码来源:SslInitializerTestUtils.java


示例5: addLocalEndpoint

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
public SocketAddress addLocalEndpoint()
{
    List list = this.endpoints;
    ChannelFuture channelfuture;

    synchronized (this.endpoints)
    {
        channelfuture = ((ServerBootstrap)((ServerBootstrap)(new ServerBootstrap()).channel(LocalServerChannel.class)).childHandler(new ChannelInitializer()
        {
            private static final String __OBFID = "CL_00001449";
            protected void initChannel(Channel p_initChannel_1_)
            {
                NetworkManager networkmanager = new NetworkManager(false);
                networkmanager.setNetHandler(new NetHandlerHandshakeMemory(NetworkSystem.this.mcServer, networkmanager));
                NetworkSystem.this.networkManagers.add(networkmanager);
                p_initChannel_1_.pipeline().addLast("packet_handler", networkmanager);
            }
        }).group(eventLoops).localAddress(LocalAddress.ANY)).bind().syncUninterruptibly();
        this.endpoints.add(channelfuture);
    }

    return channelfuture.channel().localAddress();
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:25,代码来源:NetworkSystem.java


示例6: testTryWithResourcesShouldCloseAllClustersButNotEventLoopIfProvided

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
@Test
public void testTryWithResourcesShouldCloseAllClustersButNotEventLoopIfProvided()
    throws Exception {
  EventLoopGroup eventLoop = new DefaultEventLoopGroup();
  BoundCluster cluster;
  MockClient client;

  try (Server server =
      Server.builder()
          .withAddressResolver(localAddressResolver)
          .withEventLoopGroup(eventLoop, LocalServerChannel.class)
          .build()) {

    cluster = server.register(ClusterSpec.builder().withNodes(5));
    BoundNode node = cluster.node(0);
    SocketAddress address = node.getAddress();
    client = new MockClient(eventLoop);
    client.connect(address);
  }

  // event loop should not have been closed.
  assertThat(eventLoop.isShutdown()).isFalse();
  // timer should have since a custom one was not provided.
  try {
    cluster
        .getServer()
        .timer
        .newTimeout(
            timeout -> {
              // noop
            },
            1,
            TimeUnit.SECONDS);
    fail("Expected IllegalStateException");
  } catch (IllegalStateException ise) {
    // expected
  }
  eventLoop.shutdownGracefully(0, 0, TimeUnit.SECONDS);
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:40,代码来源:ServerTest.java


示例7: testTryWithResourcesShouldCloseAllClustersButNotEventLoopAndTimerIfProvided

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
@Test
public void testTryWithResourcesShouldCloseAllClustersButNotEventLoopAndTimerIfProvided()
    throws Exception {
  EventLoopGroup eventLoop = new DefaultEventLoopGroup();
  Timer timer = new HashedWheelTimer();
  BoundCluster cluster;
  MockClient client;

  try (Server server =
      Server.builder()
          .withAddressResolver(localAddressResolver)
          .withTimer(timer)
          .withEventLoopGroup(eventLoop, LocalServerChannel.class)
          .build()) {

    cluster = server.register(ClusterSpec.builder().withNodes(5));
    BoundNode node = cluster.node(0);
    SocketAddress address = node.getAddress();
    client = new MockClient(eventLoop);
    client.connect(address);
  }

  // event loop should not have been closed.
  assertThat(eventLoop.isShutdown()).isFalse();
  // timer should not have since a custom one was not provided.
  cluster
      .getServer()
      .timer
      .newTimeout(
          timeout -> {
            // noop
          },
          1,
          TimeUnit.SECONDS);

  eventLoop.shutdownGracefully(0, 0, TimeUnit.SECONDS);
  timer.stop();
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:39,代码来源:ServerTest.java


示例8: getLocalServerBootstrap

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
ServerBootstrap getLocalServerBootstrap() {
    EventLoopGroup serverGroup = new LocalEventLoopGroup();
    ServerBootstrap sb = new ServerBootstrap();
    sb.group(serverGroup);
    sb.channel(LocalServerChannel.class);
    sb.childHandler(new ChannelInitializer<LocalChannel>() {
        @Override
        public void initChannel(LocalChannel ch) throws Exception {
        }
    });

    return sb;
}
 
开发者ID:wuyinxian124,项目名称:netty4.0.27Learn,代码行数:14,代码来源:BaseChannelTest.java


示例9: getLocalServerBootstrap

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
ServerBootstrap getLocalServerBootstrap() {
    EventLoopGroup serverGroup = new DefaultEventLoopGroup();
    ServerBootstrap sb = new ServerBootstrap();
    sb.group(serverGroup);
    sb.channel(LocalServerChannel.class);
    sb.childHandler(new ChannelInitializer<LocalChannel>() {
        @Override
        public void initChannel(LocalChannel ch) throws Exception {
        }
    });

    return sb;
}
 
开发者ID:nathanchen,项目名称:netty-netty-5.0.0.Alpha1,代码行数:14,代码来源:BaseChannelTest.java


示例10: getServerBuilder

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
@Override
protected AbstractServerImplBuilder<?> getServerBuilder() {
  return NettyServerBuilder
      .forAddress(new LocalAddress("in-process-1"))
      .flowControlWindow(65 * 1024)
      .maxMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE)
      .channelType(LocalServerChannel.class);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:9,代码来源:Http2NettyLocalChannelTest.java


示例11: setUp

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    ServerBootstrap b = new ServerBootstrap();

    LocalAddress address = LocalAddress.ANY;

    EventLoopGroup workerGroup = new NioEventLoopGroup();
    final FixAcceptorChannelInitializer<Channel> channelInitializer = new FixAcceptorChannelInitializer<>(
            workerGroup,
            new FixApplicationAdapter(),
            authenticator,
            new InMemorySessionRepository()
    );

    serverChannel = (LocalServerChannel) b.group(new NioEventLoopGroup())
            .channel(LocalServerChannel.class)
            .handler(channelInitializer)
            .childHandler(new FixApplicationAdapter())
            .validate()
            .bind(address)
            .sync()
            .channel();

    pipeline = serverChannel.pipeline();

    when(authenticator.authenticate(any(FixMessage.class))).thenReturn(true);
}
 
开发者ID:kpavlov,项目名称:fixio,代码行数:28,代码来源:ServerChannelPipelineIntegrationTest.java


示例12: testRegisterClusterFailsWhenBindTimesOut

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
@Test
public void testRegisterClusterFailsWhenBindTimesOut() throws Exception {
  // Designated address to be slow to bind.
  SocketAddress slowAddr = localAddressResolver.get();

  // create a bootstrap with a handler that delays binding by 1 second for designated address.
  ServerBootstrap serverBootstrap =
      new ServerBootstrap()
          .group(eventLoop)
          .channel(LocalServerChannel.class)
          .handler(new SlowBindHandler(slowAddr))
          .childHandler(new Server.Initializer());

  // Define server with 500ms timeout, which should cause binding of slow address to timeout and
  // fail register.
  Server flakyServer =
      new Server(
          localAddressResolver,
          eventLoop,
          true,
          new HashedWheelTimer(),
          false,
          TimeUnit.NANOSECONDS.convert(500, TimeUnit.MILLISECONDS),
          new StubStore(),
          false,
          serverBootstrap);

  // Create a 2 node cluster with 1 node having the slow address.
  ClusterSpec cluster = ClusterSpec.builder().build();
  DataCenterSpec dc = cluster.addDataCenter().build();
  dc.addNode().withAddress(slowAddr).build();
  dc.addNode().build();

  // Attempt to register which should fail.
  try {
    flakyServer.register(cluster);
    fail();
  } catch (Exception e) {
    // Expect a timeout exception.
    assertThat(e.getCause()).isInstanceOf(TimeoutException.class);
  }
}
 
开发者ID:datastax,项目名称:simulacron,代码行数:43,代码来源:ServerTest.java


示例13: isLocalChannel

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
/**
 * True if this NetworkManager uses a memory connection (single player game). False may imply both an active TCP
 * connection or simply no active connection at all
 */
public boolean isLocalChannel()
{
    return this.channel instanceof LocalChannel || this.channel instanceof LocalServerChannel;
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:9,代码来源:NetworkManager.java


示例14: isLocalChannel

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
public boolean isLocalChannel()
{
    return this.channel instanceof LocalChannel || this.channel instanceof LocalServerChannel;
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:5,代码来源:NetworkManager.java


示例15: isLocal

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
public boolean isLocal() {
    return this.channel instanceof LocalChannel || this.channel instanceof LocalServerChannel;
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:4,代码来源:NetworkManager.java


示例16: channelClass

import io.netty.channel.local.LocalServerChannel; //导入依赖的package包/类
@Override
protected Class<? extends ServerChannel> channelClass() {
    return LocalServerChannel.class;
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:5,代码来源:LocalServer.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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