<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                比較麻煩的是創建通道后不得不手動配置每個通道,為了避免這種情況,Netty 提供了 ChannelOption 來幫助引導配置。這些選項會自動應用到引導創建的所有通道,可用的各種選項可以配置底層連接的詳細信息,如通道“keep-alive(保持活躍)”或“timeout(超時)”的特性。 Netty 應用程序通常會與組織或公司其他的軟件進行集成,在某些情況下,Netty 的組件如 Channel 在 Netty 正常生命周期外使用; Netty 的提供了抽象 AttributeMap 集合,這是由 Netty 的管道和引導類,和 AttributeKey,常見類用于插入和檢索屬性值。屬性允許您安全的關聯任何數據項與客戶端和服務器的 Channel。 例如,考慮一個服務器應用程序跟蹤用戶和 Channel 之間的關系。這可以通過存儲用戶 ID 作為 Channel 的一個屬性。類似的技術可以用來路由消息到基于用戶 ID 或關閉基于用戶活動的一個管道。 清單9.7展示了如何使用 ChannelOption 配置 Channel 和一個屬性來存儲一個整數值。 Listing 9.7 Using Attributes ~~~ final AttributeKey<Integer> id = new AttributeKey<Integer>("ID"); //1 Bootstrap bootstrap = new Bootstrap(); //2 bootstrap.group(new NioEventLoopGroup()) //3 .channel(NioSocketChannel.class) //4 .handler(new SimpleChannelInboundHandler<ByteBuf>() { //5 @Override public void channelRegistered(ChannelHandlerContext ctx) throws Exception { Integer idValue = ctx.channel().attr(id).get(); //6 // do something with the idValue } @Override protected void channelRead0(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf) throws Exception { System.out.println("Reveived data"); } }); bootstrap.option(ChannelOption.SO_KEEPALIVE, true).option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 5000); //7 bootstrap.attr(id, 123456); //8 ChannelFuture future = bootstrap.connect(new InetSocketAddress("www.manning.com", 80)); //9 future.syncUninterruptibly(); ~~~ 1. 新建一個 AttributeKey 用來存儲屬性值 2. 新建 Bootstrap 用來創建客戶端管道并連接他們 3. 指定 EventLoopGroups 從和接收到的管道來注冊并獲取 EventLoop 4. 指定 Channel 類 5. 設置處理器來處理管道的 I/O 和數據 6. 檢索 AttributeKey 的屬性及其值 7. 設置 ChannelOption 將會設置在管道在連接或者綁定 8. 存儲 id 屬性 9. 通過配置的 Bootstrap 來連接到遠程主機
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看