GithubHelp home page GithubHelp logo

narzolliam / baseio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from firenio/firenio

0.0 0.0 0.0 33.52 MB

🐳🐳An [easy of use, simple, not bad of performance] io framework project based on java nio

Home Page: https://www.generallycloud.com/

License: Apache License 2.0

Java 85.52% Batchfile 0.10% Shell 0.06% HTML 0.52% JavaScript 13.50% CSS 0.30%

baseio's Introduction

BaseIO Project

Website Maven central License

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

Features

  • easy to support reconnect (easy to support heart beat)
  • simple application container
  • easy to supprot load balance, known:
    • virtual node based on hash
    • loop balance node
  • support protocol extend, known:
  • load test
    • over 200W QPS (Http1.1,I7-4790,16.04.1-Ubuntu) Β wrk load test

Quick Start

  • Maven Dependency
  <dependency>
  	<groupId>com.generallycloud</groupId>
  	<artifactId>baseio-all</artifactId>
  	<version>3.2.3.Release</version>
  </dependency>  
  • Simple Server:
  public static void main(String[] args) throws Exception {
      IoEventHandleAdaptor eventHandleAdaptor = new IoEventHandleAdaptor() {
          @Override
          public void accept(SocketSession session, Future future) throws Exception {
              future.write("yes server already accept your message:");
              future.write(future.getReadText());
              session.flush(future);
          }
      };
      SocketChannelContext context = new NioSocketChannelContext(new ServerConfiguration(18300));
      //use java aio
      //SocketChannelContext context = new AioSocketChannelContext(new ServerConfiguration(18300));
      SocketChannelAcceptor acceptor = new SocketChannelAcceptor(context);
      context.addSessionEventListener(new LoggerSocketSEListener());
      context.setIoEventHandleAdaptor(eventHandleAdaptor);
      context.setProtocolFactory(new FixedLengthProtocolFactory());
      acceptor.bind();
  }
  • Simple Client:
  public static void main(String[] args) throws Exception {
      IoEventHandleAdaptor eventHandleAdaptor = new IoEventHandleAdaptor() {
          @Override
          public void accept(SocketSession session, Future future) throws Exception {
              System.out.println();
              System.out.println("____________________" + future.getReadText());
              System.out.println();
          }
      };
      SocketChannelContext context = new NioSocketChannelContext(new ServerConfiguration("localhost", 18300));
      //use java aio
      //SocketChannelContext context = new AioSocketChannelContext(new ServerConfiguration(18300));
      SocketChannelConnector connector = new SocketChannelConnector(context);
      context.setIoEventHandleAdaptor(eventHandleAdaptor);
      context.addSessionEventListener(new LoggerSocketSEListener());
      context.setProtocolFactory(new FixedLengthProtocolFactory());
      SocketSession session = connector.connect();
      FixedLengthFuture future = new FixedLengthFutureImpl(context);
      future.write("hello server!");
      session.flush(future);
      ThreadUtil.sleep(100);
      CloseUtil.close(connector);
  }

more samples {baseio-test}

Sample at website:

License

BaseIO 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

baseio's People

Contributors

wangkaish 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.