Score
0
Watch 78 Star 157 Fork 1

FireNio / firenioJavaApache-2.0

Join us
Explore and code with more than 2 million developers,Free private repositories !:)
Sign up
基于java nio开发的一款可快速构建通讯项目的io框架 spread retract

https://www.firenio.com/

  • Java 89.8%
  • C++ 5.7%
  • JavaScript 3.1%
  • HTML 0.7%
  • CSS 0.4%
  • Other 0.3%
Clone or download
Loading...
README-en.md

FireNio Project

Website Maven central License

FireNio is an io framework which can build network project fast, it based on java nio, it is popular with Developers because of simple and easy of use APIs and high-performance.

Features

Quick Start

  • Maven Dependency
  <dependency>
  	<groupId>com.firenio</groupId>
  	<artifactId>firenio-all</artifactId>
  	<version>1.3.2</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);
  }

more samples see project {firenio-test}

Sample at website:

License

FireNio is released under the Apache License 2.0.

To learn more, join this QQ group, more java technique can talk at there.

  • QQ group NO: 540637859
  • Join by click this link: img
  • Scan QR code:
    image

Comments ( 14 )

Sign in for post a comment

Java
1
https://gitee.com/FireNio/firenio.git
git@gitee.com:FireNio/firenio.git
FireNio
firenio
firenio
master

Help Search