🚀 Ultra-lightweight Netty framework
Lightweight, fast, and ready for production — for TCP, Serial, and Bluetooth
| Feature | Description | |
|---|---|---|
| ⚡ | Lightweight | Ultra-thin wrapper over Netty 4.2.x, zero extra overhead |
| 🔌 | Multi-Protocol | TCP · Serial (Rxtx/Jsc) · Bluetooth — unified template API |
| 🧩 | Struct Serializer | Declarative binary protocol — annotate your POJO, done |
| 🔧 | Function-first | Functional handlers, interceptors, heartbeats — less boilerplate |
| 📡 | Bluetooth Ready | OIO-based Bluetooth server/client for embedded devices |
<dependency>
<groupId>io.github.fbbzl</groupId>
<artifactId>nettyx</artifactId>
<version>2.6.29</version>
</dependency>implementation 'io.github.fbbzl:nettyx:2.6.29'ServerTemplate server = new ServerTemplate(8080) {
@Override
protected ChannelInitializer<NioSocketChannel> childChannelInitializer() {
return ch -> ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
ctx.writeAndFlush(Unpooled.wrappedBuffer("Hello\n".getBytes()));
}
});
}
};
server.bind();@Struct
public class Login {
@ToCharSequence(bufferLength = 32) String username;
@ToArray(10) byte[] password;
@Chunk(length = 8) byte[] reserved;
}Login login = StructSerializer.toStruct(buf, Login.class);
byte[] bytes = StructSerializer.toBytes(login);SingleRxtxChannelTemplate serial = new SingleRxtxChannelTemplate("COM1") {
@Override
protected ChannelInitializer<RxtxChannel> channelInitializer() {
return ch -> ch.pipeline().addLast(new StringCodec());
}
};
serial.connect();
serial.writeAndFlush("Hello");BtServerTemplate btServer = new BtServerTemplate("0000110100001000800000805f9b34fb", "MyBtServer") {
@Override
protected ChannelInitializer<BtAcceptedChannel> childChannelInitializer() {
return ch -> ch.pipeline().addLast(new ChannelInboundHandlerAdapter() {
@Override
public void channelActive(ChannelHandlerContext ctx) {
System.out.println("Bt client connected: " + ctx.channel().remoteAddress());
}
});
}
};action Functional interfaces & utilities
channel Channel extensions
├── bluetooth Bluetooth OIO (client/server)
├── enhanced Optimized OIO byte stream
└── serial Rxtx / Jsc serial channels
codec Codecs
├── ByteArrayCodec Byte array ↔ ByteBuf
├── DelimiterBasedFrameCodec Delimiter-based framing
├── EscapeCodec Escape / sensitive-word replacement
├── StartEndFlagFrameCodec Start/end flag delimiter
├── StringMessageCodec String codec
└── StructCodec Struct serializer codec
event Netty event utilities
exception Custom runtime exceptions
handler Pipeline handlers
├── ChannelInterceptor Pre-read/write interception
├── ActionIdleStateHandler Parameterized idle-state handler
├── ActionReadTimeoutHandler Parameterized read timeout
├── ActionWriteTimeoutHandler Parameterized write timeout
├── ChannelAdvice Inbound / outbound advice
├── IdledHeartBeater Auto heartbeat on idle
└── MessageFilter Message content filter
serializer Serialization
└── struct Binary struct serializer (annotation-driven)
template Application templates
├── serial/jsc Multi/single Jsc channel client
├── serial/rxtx Multi/single Rxtx channel client
├── tcp/client Multi/single TCP client + server detector
├── tcp/server TCP server
└── bluetooth/server Bluetooth server
util Utilities
├── Bins Binary bit/array tools
├── BtFinder Bluetooth device scanner
├── CommPorts Serial port utility
├── EndianKit Endian conversion
├── HexKit Hex encode/decode
└── ...
mvn clean install -DskipTestsℹ️ Tests require hardware (serial ports, Bluetooth adapters). Run with caution.
| 🌐 | GitHub |
| 🇨🇳 | Gitee |
| 📖 | Blog / Examples |
| 🛠️ | JetBrains IDEA — Ultimate license sponsored |
First of all, I would like to thank my family for giving me enough time to focus on this project, then I would like to thank JetBrains for giving me the Ultimate Edition of the IDEA, and finally I would like to thank myself.
Hopefully, this framework will save you even a minute of development time.