Beispiel #1
0
  /**
   * Prepares a clientside NetworkManager: establishes a connection to the address and port supplied
   * and configures the channel pipeline. Returns the newly created instance.
   */
  public static NetworkManager provideLanClient(InetAddress p_150726_0_, int p_150726_1_) {
    final NetworkManager var2 = new NetworkManager(EnumPacketDirection.CLIENTBOUND);
    ((Bootstrap)
            ((Bootstrap)
                    ((Bootstrap)
                            (new Bootstrap())
                                .group((EventLoopGroup) CLIENT_NIO_EVENTLOOP.getValue()))
                        .handler(
                            new ChannelInitializer() {

                              protected void initChannel(Channel p_initChannel_1_) {
                                try {
                                  p_initChannel_1_
                                      .config()
                                      .setOption(ChannelOption.IP_TOS, Integer.valueOf(24));
                                } catch (ChannelException var4) {;
                                }

                                try {
                                  p_initChannel_1_
                                      .config()
                                      .setOption(ChannelOption.TCP_NODELAY, Boolean.valueOf(false));
                                } catch (ChannelException var3) {;
                                }

                                p_initChannel_1_
                                    .pipeline()
                                    .addLast("timeout", new ReadTimeoutHandler(20))
                                    .addLast("splitter", new MessageDeserializer2())
                                    .addLast(
                                        "decoder",
                                        new MessageDeserializer(EnumPacketDirection.CLIENTBOUND))
                                    .addLast("prepender", new MessageSerializer2())
                                    .addLast(
                                        "encoder",
                                        new MessageSerializer(EnumPacketDirection.SERVERBOUND))
                                    .addLast("packet_handler", var2);
                              }
                            }))
                .channel(NioSocketChannel.class))
        .connect(p_150726_0_, p_150726_1_)
        .syncUninterruptibly();
    return var2;
  }
Beispiel #2
0
  /**
   * Prepares a clientside NetworkManager: establishes a connection to the socket supplied and
   * configures the channel pipeline. Returns the newly created instance.
   */
  public static NetworkManager provideLocalClient(SocketAddress p_150722_0_) {
    final NetworkManager var1 = new NetworkManager(EnumPacketDirection.CLIENTBOUND);
    ((Bootstrap)
            ((Bootstrap)
                    ((Bootstrap)
                            (new Bootstrap())
                                .group((EventLoopGroup) CLIENT_LOCAL_EVENTLOOP.getValue()))
                        .handler(
                            new ChannelInitializer() {

                              protected void initChannel(Channel p_initChannel_1_) {
                                p_initChannel_1_.pipeline().addLast("packet_handler", var1);
                              }
                            }))
                .channel(LocalChannel.class))
        .connect(p_150722_0_)
        .syncUninterruptibly();
    return var1;
  }