Skip to content

Mindgamesnl/FireIO

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

138 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fire-IO Build Status GitHub version

Fire-IO is a lightning fast yet simple cross platform networking solution that allows you to connect and manage data from multiple platforms with one easy to use java server. The ultimate framework for your networking needs.

And all that for the sweet price of nothing.

Platforms

  • Java Java server
  • Java Client
  • JavaScript Small web client
  • PHP & Other Can make use of socket, websocket or the Rest implementation
  • Load Balancer Fire-IO comes with a real time load balancer to scale your application.
  • Rancher Working within rancher environments with active proxy

Features

  • Events All event driven API
  • Content types Send objects, strings and more with build in (de)serialisation
  • Web Compatible with your web application via our REST service and automatic websocket implementation
  • Data Loss Prevention Automatically detect the failure of a packet and try to repair the data or resend it
  • Auto Reconnect Auto reconnect for all-clients
  • Rate Limiter Build in rate limiter for all your endpoints (rest, api and socket)
  • Async All networking is done in async at all times and events are correctly handled via pools, so no more worrying about response times.
  • Requests Handle requests from clients, assign a response to one specific piece of data
  • Passwords Password protection for your network, don't allow connections without a key
  • Load Balancer improve the reliability and response times of your applications by setting up load balancers to evenly spread the request and connections among your servers.

Useful Links

FireIO depends on:

  • Java 8

Example code

Here is a simple example setup with a server, client, a custom packet, two way data communication and a non blocking data request including a callback

Example Java server

FireIoServer server = new FireIoServer(80)
    .setPassword("testpassword1")
    .setRateLimiter(2, 10)

.on(Event.CONNECT, client -> {
    client.send("MOTD", "test");
})

.on(Event.TIMED_OUT, client -> {
    System.out.println(client.getId() + " closed unexpectedly! " + client.getConnectionType());
})

.on(Event.DISCONNECT, client -> {
    System.out.println(client.getId() + " just disconnected");
})

.onPacket(CookieJar.class, "cookie_jar").onExecute((sender, cookieJar) -> {
    System.out.println("Received a cookie jar from : " + sender.getId() + ". The jar contains " + cookieJar.getAmount() + " cookies. The cookies type is: " + cookieJar.getType());
    //thank the client for the cookies
    sender.send("thanks", "thanks");
});

//simple request based endpoint
server.onRequest("whoami", (client, request, response) -> {
    System.out.println(client.getId().toString() + " asked who it is! sending ip back");
    response.complete(new RequestString("You are: " + client.getInfo().getHostname()));
});

//http time endpoint
server.registerEndpoint("/time", (req, settings) -> {
    return "The server time is: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
});

//one with a variable, the path is set to /hi/?name
//this will mean that ?name will be a variable, example
server.registerEndpoint("/hi/?name", (req, settings)  -> {
    return "Welcome to FireIO " + req.getVariable("name") + "!";
});

Web JavaScript Client

<script src="Fire-IO.js"></script>
<script>
    const client = new FireIoClient("localhost", 80);
    client.setPassword("testpassword1");
    client.setAutoReconnect(500);
    client.connect();
    
    client.on("connect", function () {
        console.log("connected!!");
        client.send("channel", "Hello world!");
    });
    
    client.on("channel", function (data) {
        console.log("The server said: " + data);
    });
    
    client.on("disconnect", function () {
        console.log("disconnected!!");
    });
</script>

Example Java Client

FireIoClient client = new FireIoClient("localhost", 80)
        .setPassword("testpassword1")
        .setAutoReConnect(2000)
        .setParameter("appversion", "1.0-RELEASE")
        .connect();

.on(Event.CONNECT, ignored -> {
    System.out.println("Connected with the server!");
})

.on(Event.DISCONNECT, ignored -> {
    System.out.println("Connection with the server has closed!");
})

.on("channel", (client, message) -> {
    System.out.println("The message of the day is: " + message);
    //send a cookie jar
    client.send("cookie_jar", new CookieJar(5, "chocolate"));
})

.on("thanks", (client, message) -> {
    System.out.println("The server thanked you for your cookies");
});

Example Custom Java packet (object)

public class CookieJar extends Packet {
    private int amount = 0;
    private String type;
}

About

The simple fast, simple and sexy cross platform networking framework

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors