Skip to content

🐳🐳An easy of use io framework project based on java nio&epoll

License

Notifications You must be signed in to change notification settings

FireNio/firenio

Repository files navigation

FireNio Project

Website Maven central License

FireNio是基于java nio开发的一款可快速构建网络通讯项目的异步IO框架,其以简单易用的API和优良的性能深受开发者喜爱。

项目特色

快速入门

  • Maven引用:
  <dependency>
  	<groupId>com.firenio</groupId>
  	<artifactId>firenio-all</artifactId>
  	<version>1.3.6</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.allocateWithSkipHeader(1));
              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);
      ch.writeAndFlush(frame);
  }

更多样例详见 {firenio-test}

演示及用例

License

FireNio is released under the Apache License 2.0.

About

🐳🐳An easy of use io framework project based on java nio&epoll

https://firenio.com(No Served)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published