mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 18:08:37 +01:00
make delayed sending slightly faster
This commit is contained in:
parent
6f9a92ac76
commit
a61034fc1d
@ -163,16 +163,17 @@ public class NettyPlayerConnection extends PlayerConnection {
|
|||||||
if (message instanceof FramedPacket) {
|
if (message instanceof FramedPacket) {
|
||||||
final FramedPacket framedPacket = (FramedPacket) message;
|
final FramedPacket framedPacket = (FramedPacket) message;
|
||||||
synchronized (tickBuffer) {
|
synchronized (tickBuffer) {
|
||||||
// Copy is necessary because of cached packets
|
// Duplicate is necessary because of cached packets
|
||||||
tickBuffer.writeBytes(framedPacket.getBody().copy());
|
tickBuffer.writeBytes(framedPacket.getBody().duplicate());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else if (message instanceof ServerPacket) {
|
} else if (message instanceof ServerPacket) {
|
||||||
final ServerPacket serverPacket = (ServerPacket) message;
|
final ServerPacket serverPacket = (ServerPacket) message;
|
||||||
final ByteBuf buffer = PacketUtils.createFramedPacket(serverPacket, false);
|
final ByteBuf buffer = PacketUtils.createFramedPacket(serverPacket, true);
|
||||||
synchronized (tickBuffer) {
|
synchronized (tickBuffer) {
|
||||||
tickBuffer.writeBytes(buffer);
|
tickBuffer.writeBytes(buffer);
|
||||||
}
|
}
|
||||||
|
buffer.release();
|
||||||
return;
|
return;
|
||||||
} else if (message instanceof ByteBuf) {
|
} else if (message instanceof ByteBuf) {
|
||||||
synchronized (tickBuffer) {
|
synchronized (tickBuffer) {
|
||||||
@ -200,9 +201,7 @@ public class NettyPlayerConnection extends PlayerConnection {
|
|||||||
synchronized (tickBuffer) {
|
synchronized (tickBuffer) {
|
||||||
final ByteBuf copy = tickBuffer.copy();
|
final ByteBuf copy = tickBuffer.copy();
|
||||||
|
|
||||||
ChannelFuture channelFuture = channel.write(new FramedPacket(copy)).addListener(future -> {
|
ChannelFuture channelFuture = channel.write(new FramedPacket(copy)).addListener(future -> copy.release());
|
||||||
copy.release();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Netty debug
|
// Netty debug
|
||||||
if (MinecraftServer.shouldProcessNettyErrors()) {
|
if (MinecraftServer.shouldProcessNettyErrors()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user