Git Product home page Git Product logo

jfastnet's Introduction

JFastNet

Fast, reliable and easy UDP messaging for Java. Designed for games.

JFastNet is tolerant towards packet loss and when used in the right way it can provide your players with a smooth network gaming experience even in bad network conditions.

The API of this library is subject to change.

Maven

The dependency for your POM:

<dependency>
    <groupId>com.jfastnet</groupId>
    <artifactId>jfastnet</artifactId>
    <version>0.3.1</version>
</dependency>

Example code

The following code shows the important parts of a server-client communication:

Server server = new Server(new Config().setBindPort(15150));
Client client = new Client(new Config().setPort(15150));

server.start();
client.start();
client.blockingWaitUntilConnected();

server.send(new PrintMessage("Hello Client!"));
client.send(new PrintMessage("Hello Server!"));

Click to see full sample code of HelloWorld.java

Roadmap

  • More documentation

Documentation

The documentation is still a work-in-progress.

The most important classes to look for in the beginning are the Config and the Message class. The JavaDoc there should provide you with the basic configuration possibilities of the library.

Reliable sending

There are currently two ways you can use to send a message in a reliable way. Sending the message unreliably is of course also an option.

  1. Acknowledge packet
  2. Sequence number

Acknowledge packet

The receiver of a message with reliable mode set to ACK_PACKET will send an acknowledge packet to the other end upon receipt of the message. As long as the sender of the prior mentioned message doesn't receive an acknowledge packet it will keep resending the message.

Attribute Value
Reliable yes
Ordered no

Sequence number

The receiver of a message with reliable mode set to SEQUENCE_NUMBER will do nothing as long as the messages arrive in the expected order. But if a message with an id greater than expected is received, the receiver will stop processing the messages and send a RequestSeqIdsMessage to the other end. Processing will not continue until all required messages are received.

Attribute Value
Reliable yes
Ordered yes

It's usually advisable to use sequence numbers, as there will be less overhead and also the ordered delivery is guaranteed.

Build

Use maven to build JFastNet:

mvn clean install

Thanks

Kryo is the default serialiser used in JFastNet and is a pleasure to work with! Thanks very much for this awesome library!

Project Lombok also deserves a mention, as it makes working with Java much more comfortable and the code looks cleaner. Check it out if you don't have already.

Contact

Post issues to the issues page or contact me via email at [email protected] for other inquiries.

jfastnet's People

Contributors

klaus7 avatar

Watchers

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