Giter Club home page Giter Club logo

sbenlib's Introduction

SBENLib

This library provides a complete network system which is very easy to use. You are able to create a whole network with only a few lines!
The other very great feature of this library is that you are able decide easily between the protocols UDP or TCP and between ZLib and GLib.
An other great feature is that you are able to decide between a secured or a normal data packet.
A secured packet is getting encrypted before it's getting send.
If you are using UDP as a protocol you are able different priorities for your data packet: You are able to decide if it's not important that the packet is getting lost, if the packet shouldn't get lost but the order isn't important or if the packet shouldn't get lost and the order should be correct.

Code examples

Server:

final SBENServer server = new SBENServer(new ConnectionInfo("localhost", 6234, ProtocolType.UDP, CompressionType.ZLib), 1 /* Max clients */){
  public void onSessionRequest(Session session){
    session.registerListener(new SessionEventListener(){
      public void onStateChange(ConnectionState state){
        if(state == ConnectionState.CONNECTED){
          // Client is now connected
        }
      }

      public void onPacketReceive(DataPacket packet){
        // Received packet
      }

      public void onDisconnect(String reason){
        // If client disconnected. Reason is never null.
      }
    });
  }
};
final boolean success = server.run() == ServerStartInfo.SUCCESS;

Client:

final SBENServerConnection client = new SBENServerConnection(new ConnectionInfo("localhost", 6234, ProtocolType.UDP, CompressionType.ZLib)){
  public void onStateChange(ConnectionState state){
    if(state == ConnectionState.CONNECTED){
      // Client is now connected
    }
  }

  public void onPacketReceive(DataPacket packet){
     // Received packet
  }

  public void onDisconnect(String reason){
    // If client disconnected. Reason is never null.
  }
};
final boolean success = server.run();

State

This library is currently fully working, but a 100% functionality is not guaranteed.

Requirements

  • Lombok
  • Java 7 or higher

Copyright

(c) 2018 Marcely.de

License

BSD-3-Clause

sbenlib's People

Contributors

mrealderson avatar

Stargazers

 avatar  avatar

Watchers

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