diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-04-20 19:05:14 +0200 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-04-20 19:05:14 +0200 |
commit | 483a878b8bcf1feb789cb5fd9374d0a060cc4d8a (patch) | |
tree | fb56faee3872a85282e2fa88235580589c826e45 /src/main/java/net/minecraft/server/NetworkManager.java | |
parent | ac9f297445a6116c5bb314b3be9f38520a58845e (diff) | |
download | craftbukkit-483a878b8bcf1feb789cb5fd9374d0a060cc4d8a.tar craftbukkit-483a878b8bcf1feb789cb5fd9374d0a060cc4d8a.tar.gz craftbukkit-483a878b8bcf1feb789cb5fd9374d0a060cc4d8a.tar.lz craftbukkit-483a878b8bcf1feb789cb5fd9374d0a060cc4d8a.tar.xz craftbukkit-483a878b8bcf1feb789cb5fd9374d0a060cc4d8a.zip |
Update for 1.4_00_01 -- if you bypassed Bukkit, you will most likely break.
Diffstat (limited to 'src/main/java/net/minecraft/server/NetworkManager.java')
-rw-r--r-- | src/main/java/net/minecraft/server/NetworkManager.java | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java index 649de1d9..6fd24057 100644 --- a/src/main/java/net/minecraft/server/NetworkManager.java +++ b/src/main/java/net/minecraft/server/NetworkManager.java @@ -2,15 +2,13 @@ package net.minecraft.server; import java.io.DataInputStream; import java.io.DataOutputStream; -import java.io.IOException; import java.net.Socket; import java.net.SocketAddress; -import java.net.SocketException; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; + +import java.io.IOException; // CraftBukkit public class NetworkManager { @@ -18,10 +16,10 @@ public class NetworkManager { public static int b; public static int c; private Object e = new Object(); - public Socket f; // CraftBukkit private->public + public Socket socket; // CraftBukkit -- private->public private final SocketAddress g; - private DataInputStream h; - private DataOutputStream i; + private DataInputStream input; + private DataOutputStream output; private boolean j = true; private List k = Collections.synchronizedList(new ArrayList()); private List l = Collections.synchronizedList(new ArrayList()); @@ -39,25 +37,18 @@ public class NetworkManager { private int w = 50; public NetworkManager(Socket socket, String s, NetHandler nethandler) { - this.f = socket; + this.socket = socket; this.g = socket.getRemoteSocketAddress(); this.n = nethandler; - // Craftbukkit start try { - socket.setSoTimeout(30000); + socket.setSoTimeout(30000); // Craftbukkit start socket.setTrafficClass(24); - } catch (SocketException socketexception) { + this.input = new DataInputStream(socket.getInputStream()); + this.output = new DataOutputStream(socket.getOutputStream()); + } catch (IOException socketexception) { System.err.println(socketexception.getMessage()); } - - try { - this.h = new DataInputStream(socket.getInputStream()); - this.i = new DataOutputStream(socket.getOutputStream()); - } catch (IOException ex) { - Logger.getLogger(NetworkManager.class.getName()).log(Level.SEVERE, null, ex); - } - // Craftbukkit end this.q = new NetworkReaderThread(this, s + " read thread"); this.p = new NetworkWriterThread(this, s + " write thread"); @@ -90,7 +81,7 @@ public class NetworkManager { Object object; Packet packet; - if (!this.l.isEmpty() && (this.d == 0 || System.currentTimeMillis() - ((Packet) this.l.get(0)).j >= (long) this.d)) { + if (!this.l.isEmpty() && (this.d == 0 || System.currentTimeMillis() - ((Packet) this.l.get(0)).timestamp >= (long) this.d)) { flag = false; object = this.e; synchronized (this.e) { @@ -98,10 +89,10 @@ public class NetworkManager { this.v -= packet.a() + 1; } - Packet.a(packet, this.i); + Packet.a(packet, this.output); } - if ((flag || this.w-- <= 0) && !this.m.isEmpty() && (this.d == 0 || System.currentTimeMillis() - ((Packet) this.m.get(0)).j >= (long) this.d)) { + if ((flag || this.w-- <= 0) && !this.m.isEmpty() && (this.d == 0 || System.currentTimeMillis() - ((Packet) this.m.get(0)).timestamp >= (long) this.d)) { flag = false; object = this.e; synchronized (this.e) { @@ -109,7 +100,7 @@ public class NetworkManager { this.v -= packet.a() + 1; } - Packet.a(packet, this.i); + Packet.a(packet, this.output); this.w = 50; } @@ -127,7 +118,7 @@ public class NetworkManager { private void f() { try { - Packet packet = Packet.b(this.h); + Packet packet = Packet.b(this.input); if (packet != null) { this.k.add(packet); @@ -155,22 +146,22 @@ public class NetworkManager { this.j = false; try { - this.h.close(); - this.h = null; + this.input.close(); + this.input = null; } catch (Throwable throwable) { ; } try { - this.i.close(); - this.i = null; + this.output.close(); + this.output = null; } catch (Throwable throwable1) { ; } try { - this.f.close(); - this.f = null; + this.socket.close(); + this.socket = null; } catch (Throwable throwable2) { ; } @@ -203,7 +194,7 @@ public class NetworkManager { } } - public SocketAddress b() { + public SocketAddress getSocketAddress() { return this.g; } |