An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
An easy-to-use, event-driven, asynchronous network application framework compiled with Java 11.
SimpleNet is a simplistic, client-server framework written in Java. One or more Client objects can connect to a Server and send data back-and-forth via TCP. Most methods that read data from the network are non-blocking and are invoked asynchronously when the requested data arrives. Not having to block a thread and wait for data is what makes SimpleNet scalable for different types of applications such as chat servers, multiplayer game servers, and so much more!
Maven:
com.github.jhg023
SimpleNet
1.6.6
Gradle:
implementation 'com.github.jhg023:SimpleNet:1.6.6'module-info.java:module my.project {
requires com.github.simplenet;
}n, and specify what should be done with those n bytes, as if the Client or Server has already received them.// Request a single byte and print it out when it arrives.
client.readByte(System.out::println);
// Continuously request a single byte and print it out when it arrives.
//
// After the callback completes, another byte will be requested automatically,
// and the same callback will be invoked. This continues until the connection is closed.
client.readByteAlways(System.out::println);Client to a Server (and vice versa) via the Packet class.……… To emphasize how easy it is to use SimpleNet, I have written an implementation of a scalable chat server below. Note how only two classes are required, ChatServer and ChatClient. Ideally, a chat server should use a GUI and not the console, as this leads to message cut-off in the window, but this is only to serve as a proof-of-concept.
The full ChatServer implementation is as follows:
… The full ChatClient implementation is as follows:
…onConnect callback?onConnect callback is performed asynchronously.Client be used with some unrelated server and vice-versa?Client and Server have an overloaded constructor that accepts a buffer size in bytes. You can simply specify a size larger than 8192 (the default size).No open issues yet, or sync has not completed.