1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        FireNio構(gòu)建通訊項(xiàng)目的異步 io 框架

        聯(lián)合創(chuàng)作 · 2023-09-29 12:17

        FireNio Project

        FireNio 是基于 java nio 開發(fā)的一款可快速構(gòu)建網(wǎng)絡(luò)通訊項(xiàng)目的異步 IO 框架,其以簡(jiǎn)單易用的 API 和優(yōu)良的性能深受開發(fā)者喜愛。

        項(xiàng)目特色

        • 支持協(xié)議擴(kuò)展,已知的擴(kuò)展協(xié)議有:
        • 輕松實(shí)現(xiàn)斷線重連(輕松實(shí)現(xiàn)心跳機(jī)制)
        • 支持SSL(jdkssl,openssl)
        • 壓力測(cè)試

        快速入門

        • Maven引用:
          <dependency>
          	<groupId>com.firenio</groupId>
          	<artifactId>firenio-all</artifactId>
          	<version>1.2.1</version>
          </dependency>  
        • Simple Server:
          public static void main(String[] args) throws Exception {
        
              IoEventHandle eventHandleAdaptor = new IoEventHandle() {
        
                  @Override
                  public void accept(Channel ch, Frame f) throws Exception {
                      String text = f.getStringContent();
                      f.setContent(ch.allocate());
                      f.write("yes server already accept your message:", ch);
                      f.write(text, ch);
                      ch.writeAndFlush(f);
                  }
              };
              ChannelAcceptor context = new ChannelAcceptor(8300);
              context.addChannelEventListener(new LoggerChannelOpenListener());
              context.setIoEventHandle(eventHandleAdaptor);
              context.addProtocolCodec(new LengthValueCodec());
              context.bind();
          }
        
        • Simple Client:
          public static void main(String[] args) throws Exception {
              ChannelConnector context = new ChannelConnector("127.0.0.1", 8300);
              IoEventHandle eventHandle = new IoEventHandle() {
                  @Override
                  public void accept(Channel ch, Frame f) throws Exception {
                      System.out.println();
                      System.out.println("____________________" + f.getStringContent());
                      System.out.println();
                      context.close();
                  }
              };
        
              context.setIoEventHandle(eventHandle);
              context.addChannelEventListener(new LoggerChannelOpenListener());
              context.addProtocolCodec(new LengthValueCodec());
              Channel ch = context.connect(3000);
              LengthValueFrame frame = new LengthValueFrame();
              frame.setString("hello server!");
              ch.writeAndFlush(frame);
          }
        

        更多樣例詳見 {firenio-test}

        演示及用例

        License

        FireNio is released under the Apache License 2.0.

        瀏覽 29
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        評(píng)論
        圖片
        表情
        推薦
        點(diǎn)贊
        評(píng)論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            疯狂刺激的3p视频在线 | 女人被狂躁60分钟视频 | 无码一区二区三区四 | 色av综合网站 | 久操免费视频 | 中国女孩操逼视频 | 国产伦理片在线播放 | 国产精品成人无码a v在线观看 | 亚洲人人操 | 91国产精品一区 |