Simple, performant message library for Java.
Go to file
Andrew Lalis 3fc0efca5f Refactored completely for version 2.0.0 2023-09-21 18:35:19 -04:00
src Refactored completely for version 2.0.0 2023-09-21 18:35:19 -04:00
.gitignore Added first version stuff. 2022-04-16 13:03:21 +02:00
LICENSE Initial commit 2022-04-16 11:05:09 +02:00
README.md Refactored completely for version 2.0.0 2023-09-21 18:35:19 -04:00
jitpack.yml Updated with jitpack config for explicit use of java 17 2022-07-05 20:39:00 +02:00
pom.xml Refactored completely for version 2.0.0 2023-09-21 18:35:19 -04:00

README.md

record-net

Simple, performant message library for Java, using records.

record-net gives you the advantages of reflection, without the runtime costs. By registering message types before starting your work, record-net is able to generate custom serializers and deserializers for all registered message types, which translates to read and write speeds that are nearly equivalent to directly writing bytes to a stream.

Here's an example of how you can use record-net:

import com.andrewlalis.record_net.Message;
import com.andrewlalis.record_net.impl.TypeMappedSerializer;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.Socket;

class Example {
    record ChatMessage(
            long timestamp,
            String username,
            String msg
    ) implements Message {
    }

    public static void main(String[] args) throws IOException {
        var ser = new TypeMappedSerializer();
        ser.registerType(1, ChatMessage.class);
        var socket = new Socket("127.0.0.1", 8081);
        var bOut = new ByteArrayOutputStream();
        var msg = new ChatMessage(
                System.currentTimeMillis(),
                "andrew",
                "Hello world!"
        );
        ser.writeMessage(msg, socket.getOutputStream());
        ChatMessage response = (ChatMessage) ser.readMessage(socket.getInputStream());
    }
}

Get record-net

This project is published as a package on GitHub. You can view available packages here. Alternatively, you can get this project on jitpack.io.