Increment written bytes value

This commit is contained in:
md_5 2013-04-28 08:29:00 +10:00
parent 8a035561c6
commit f5a5b2bd76

View File

@ -1,4 +1,4 @@
From f6adddd68afa44beb63b7da41c1ee732bb24d482 Mon Sep 17 00:00:00 2001 From 6d03a8b1c00c39c32edbaa447e41a8f1b7e5b2be Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Tue, 23 Apr 2013 11:47:32 +1000 Date: Tue, 23 Apr 2013 11:47:32 +1000
Subject: [PATCH] Netty Subject: [PATCH] Netty
@ -449,10 +449,10 @@ index 0000000..2dbbf6c
+} +}
diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
new file mode 100644 new file mode 100644
index 0000000..f581384 index 0000000..319e22a
--- /dev/null --- /dev/null
+++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java +++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
@@ -0,0 +1,293 @@ @@ -0,0 +1,290 @@
+package org.spigotmc.netty; +package org.spigotmc.netty;
+ +
+import com.google.common.util.concurrent.ThreadFactoryBuilder; +import com.google.common.util.concurrent.ThreadFactoryBuilder;
@ -639,6 +639,7 @@ index 0000000..f581384
+ throw new RuntimeException("Writing packet", ex); + throw new RuntimeException("Writing packet", ex);
+ } + }
+ } + }
+ writtenBytes += buf.readableBytes();
+ +
+ channel.write(buf).addListener(new ChannelFutureListener() { + channel.write(buf).addListener(new ChannelFutureListener() {
+ public void operationComplete(ChannelFuture future) throws Exception { + public void operationComplete(ChannelFuture future) throws Exception {
@ -741,10 +742,6 @@ index 0000000..f581384
+ public long getWrittenBytes() { + public long getWrittenBytes() {
+ return writtenBytes; + return writtenBytes;
+ } + }
+
+ public void addWrittenBytes(int written) {
+ writtenBytes += written;
+ }
+} +}
diff --git a/src/main/java/org/spigotmc/netty/NettyServerConnection.java b/src/main/java/org/spigotmc/netty/NettyServerConnection.java diff --git a/src/main/java/org/spigotmc/netty/NettyServerConnection.java b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
new file mode 100644 new file mode 100644
@ -1158,7 +1155,7 @@ index 0000000..65074d2
+} +}
diff --git a/src/main/java/org/spigotmc/netty/PacketEncoder.java b/src/main/java/org/spigotmc/netty/PacketEncoder.java diff --git a/src/main/java/org/spigotmc/netty/PacketEncoder.java b/src/main/java/org/spigotmc/netty/PacketEncoder.java
new file mode 100644 new file mode 100644
index 0000000..c8832d6 index 0000000..69dff43
--- /dev/null --- /dev/null
+++ b/src/main/java/org/spigotmc/netty/PacketEncoder.java +++ b/src/main/java/org/spigotmc/netty/PacketEncoder.java
@@ -0,0 +1,50 @@ @@ -0,0 +1,50 @@
@ -1175,6 +1172,7 @@ index 0000000..c8832d6
+ * Netty encoder which takes a packet and encodes it, and adds a byte packet id + * Netty encoder which takes a packet and encodes it, and adds a byte packet id
+ * header. + * header.
+ */ + */
+// TODO: Remove this
+public class PacketEncoder extends MessageToByteEncoder<Packet> { +public class PacketEncoder extends MessageToByteEncoder<Packet> {
+ +
+ private ByteBuf outBuf; + private ByteBuf outBuf;
@ -1197,7 +1195,6 @@ index 0000000..c8832d6
+ out.writeByte(msg.n()); + out.writeByte(msg.n());
+ msg.a(dataOut); + msg.a(dataOut);
+ +
+ networkManager.addWrittenBytes(outBuf.readableBytes());
+ out.writeBytes(outBuf); + out.writeBytes(outBuf);
+ out.discardSomeReadBytes(); + out.discardSomeReadBytes();
+ } + }