Unet
1.0.0
UNET是使用Pure Java開發的輕巧且高性能的UDP網絡框架,它基於事件模型驅動器和使用的同步非塊IO。
Unet unet = Unet . spawn ( new UnetConfig (). bindPort ( 1234 ));
unet . pipeline (). addInboundHandler ( buffer -> {
// Do something...
// Pass to the next processor
UnetContext . doRead ( buffer );
}). addInboundHandler ( buffer -> {
// Do something...
}). addOutboundHandler ( buffer -> {
// Outbound handler chain
// Do something
UnetContext . doSend ( buffer );
});
// Async send messages
unet . fireSend (
ByteBuffer . wrap ( "hello" . getBytes ( StandardCharsets . UTF_8 )),
new InetSocketAddress ( "target address" , 1234 )
);
// Sync send messages
unet . fireSend (
ByteBuffer . wrap ( "hello" . getBytes ( StandardCharsets . UTF_8 )),
new InetSocketAddress ( "target address" , 1234 )
). sync ();
// sync call is synchronized, is equivalent to this
unet . pipeline (). doSend (
ByteBuffer . wrap ( "hello" . getBytes ( StandardCharsets . UTF_8 )),
new InetSocketAddress ( "target address" , 1234 )
);
// Broadcast
unet . fireBroadcast (
ByteBuffer . wrap ( "hello" . getBytes ( StandardCharsets . UTF_8 )),
1234
);要求
命令
mvn clean package現在,您可以在目標文件夾中看到它。