Coder Social home page Coder Social logo

strogo / firenio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from firenio/firenio

0.0 1.0 0.0 697 KB

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

Home Page: https://firenio.com

License: Apache License 2.0

Batchfile 0.09% Java 89.53% HTML 0.70% CSS 0.46% JavaScript 3.15% Shell 0.07% Lua 0.01% Makefile 0.10% C++ 5.84% C 0.06%

firenio's Introduction

FireNio Project

Website Maven central License

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

项目特色

快速入门

  • Maven引用:
  <dependency>
  	<groupId>com.firenio</groupId>
  	<artifactId>firenio-all</artifactId>
  	<version>1.3.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.

了解更多,加入该项目QQ群,更多java相关技术均可在此讨论

  • QQ群号码:540637859
  • 点击链接加入:img
  • 扫码加入:
    image

firenio's People

Contributors

wangkaish avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.