diff --git a/src/main/java/fr/pandacube/java/util/network/client/TCPClient.java b/src/main/java/fr/pandacube/java/util/network/client/TCPClient.java index 02c815a..c84960b 100644 --- a/src/main/java/fr/pandacube/java/util/network/client/TCPClient.java +++ b/src/main/java/fr/pandacube/java/util/network/client/TCPClient.java @@ -25,7 +25,7 @@ import fr.pandacube.java.util.network.packet.PacketClient; import fr.pandacube.java.util.network.packet.PacketException; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.ResponseCallback; -import fr.pandacube.java.util.network.packet.packets.global.PacketServerException; +import fr.pandacube.java.util.network.packet.packets.global.PacketD0ServerException; import org.javatuples.Pair; public class TCPClient extends Thread implements Closeable { @@ -83,10 +83,10 @@ public class TCPClient extends Thread implements Closeable { if (!(p instanceof PacketServer)) throw new PacketException(p.getClass().getCanonicalName() + " is not a subclass of PacketServer"); - if (p instanceof PacketServerException) { + if (p instanceof PacketD0ServerException) { try { - listener.onServerException(this, ((PacketServerException)p).getExceptionString()); + listener.onServerException(this, ((PacketD0ServerException)p).getExceptionString()); } catch (Exception e) { Log.severe("Exception while calling TCPClientListener.onServerException()", e); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/Packet.java b/src/main/java/fr/pandacube/java/util/network/packet/Packet.java index e987b58..007bca0 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/Packet.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/Packet.java @@ -9,20 +9,20 @@ import fr.pandacube.java.Pandacube; import fr.pandacube.java.util.Log; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteSerializable; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketClientClose; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketClientDeclareProcess; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketClientProcessQueryResponse; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketServerClose; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketServerConnectSuccess; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketServerProcessDeclarationConfirm; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketServerProcessInput; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketServerProcessQuery; -import fr.pandacube.java.util.network.packet.packets.global.PacketClientAuthenticate; -import fr.pandacube.java.util.network.packet.packets.global.PacketClientLogRecord; -import fr.pandacube.java.util.network.packet.packets.global.PacketServerCantAuthenticate; -import fr.pandacube.java.util.network.packet.packets.global.PacketServerException; -import fr.pandacube.java.util.network.packet.packets.web.PacketClientWebRequest; -import fr.pandacube.java.util.network.packet.packets.web.PacketServerWebResponse; +import fr.pandacube.java.util.network.packet.packets.core_slave.Packet31ClientClose; +import fr.pandacube.java.util.network.packet.packets.core_slave.Packet30ClientDeclareProcess; +import fr.pandacube.java.util.network.packet.packets.core_slave.Packet32ClientProcessQueryResponse; +import fr.pandacube.java.util.network.packet.packets.core_slave.PacketB0ServerClose; +import fr.pandacube.java.util.network.packet.packets.core_slave.PacketB2ServerConnectSuccess; +import fr.pandacube.java.util.network.packet.packets.core_slave.PacketB1ServerProcessDeclarationConfirm; +import fr.pandacube.java.util.network.packet.packets.core_slave.PacketB3ServerProcessInput; +import fr.pandacube.java.util.network.packet.packets.core_slave.PacketB4ServerProcessQuery; +import fr.pandacube.java.util.network.packet.packets.global.Packet50ClientAuthenticate; +import fr.pandacube.java.util.network.packet.packets.global.Packet51ClientLogRecord; +import fr.pandacube.java.util.network.packet.packets.global.PacketD1ServerCantAuthenticate; +import fr.pandacube.java.util.network.packet.packets.global.PacketD0ServerException; +import fr.pandacube.java.util.network.packet.packets.web.Packet00ClientWebRequest; +import fr.pandacube.java.util.network.packet.packets.web.Packet80ServerWebResponse; /**
* Identification des packets réseaux @@ -96,22 +96,22 @@ public abstract class Packet implements ByteSerializable { /* * Ajout des types de packets (client + serveur) */ - addPacket(PacketClientClose.class); - addPacket(PacketClientDeclareProcess.class); - addPacket(PacketClientProcessQueryResponse.class); - addPacket(PacketServerClose.class); - addPacket(PacketServerConnectSuccess.class); - addPacket(PacketServerProcessDeclarationConfirm.class); - addPacket(PacketServerProcessInput.class); - addPacket(PacketServerProcessQuery.class); + addPacket(Packet31ClientClose.class); + addPacket(Packet30ClientDeclareProcess.class); + addPacket(Packet32ClientProcessQueryResponse.class); + addPacket(PacketB0ServerClose.class); + addPacket(PacketB2ServerConnectSuccess.class); + addPacket(PacketB1ServerProcessDeclarationConfirm.class); + addPacket(PacketB3ServerProcessInput.class); + addPacket(PacketB4ServerProcessQuery.class); - addPacket(PacketClientAuthenticate.class); - addPacket(PacketClientLogRecord.class); - addPacket(PacketServerCantAuthenticate.class); - addPacket(PacketServerException.class); + addPacket(Packet50ClientAuthenticate.class); + addPacket(Packet51ClientLogRecord.class); + addPacket(PacketD1ServerCantAuthenticate.class); + addPacket(PacketD0ServerException.class); - addPacket(PacketClientWebRequest.class); - addPacket(PacketServerWebResponse.class); + addPacket(Packet00ClientWebRequest.class); + addPacket(Packet80ServerWebResponse.class); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/bytebuffer/Array8Bit.java b/src/main/java/fr/pandacube/java/util/network/packet/bytebuffer/Array8Bit.java index 07232f4..a7c3280 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/bytebuffer/Array8Bit.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/bytebuffer/Array8Bit.java @@ -2,37 +2,31 @@ package fr.pandacube.java.util.network.packet.bytebuffer; import java.util.Arrays; -public class Array8Bit { +public class Array8Bit implements ByteSerializable { - public static final int BIT_COUNT = 8; + public static final int BIT_COUNT = Byte.SIZE; private boolean[] values = new boolean[BIT_COUNT]; - /** - * - * @param b unsigned integer value. Lowest significant bit will be used. - */ - public Array8Bit(int b) { - for (int i = 0; i>= 1; - } + public Array8Bit(byte b) { + fromByte(b); } - - + + /** + * @param bits (index 0 is the lowest significant bit) + */ public Array8Bit(boolean[] bits) { if (bits == null || bits.length != BIT_COUNT) throw new IllegalArgumentException("bits is null or bits.length != "+BIT_COUNT); values = Arrays.copyOf(bits, BIT_COUNT); } - /** * i = 0 is the lowest significant bit * @param i * @return */ - public boolean getValue(int i) { + public boolean getBit(int i) { return values[i]; } @@ -41,12 +35,23 @@ public class Array8Bit { * @param i * @param b */ - public void setValue(int i, boolean b) { + public void setBit(int i, boolean b) { values[i] = b; } - public byte getValuesAsByte() { + + public void fromByte(byte b) { + int mask = 1; + for (int i = 0; i < BIT_COUNT; i++) { + values[i] = (b & mask) != 0; + mask <<= 1; + } + } + + + + public byte toByte() { byte b = 0; for (int i=BIT_COUNT-1; i>=0; i--) { b <<= 1; @@ -55,4 +60,18 @@ public class Array8Bit { return b; } + + + + @Override + public void deserializeFromByteBuffer(ByteBuffer buffer) { + fromByte(buffer.getByte()); + } + + @Override + public void serializeToByteBuffer(ByteBuffer buffer) { + buffer.putByte(toByte()); + } + + } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientDeclareProcess.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet30ClientDeclareProcess.java similarity index 87% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientDeclareProcess.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet30ClientDeclareProcess.java index aba01d4..3cc8b2d 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientDeclareProcess.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet30ClientDeclareProcess.java @@ -3,12 +3,12 @@ package fr.pandacube.java.util.network.packet.packets.core_slave; import fr.pandacube.java.util.network.packet.PacketClient; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketClientDeclareProcess extends PacketClient { +public class Packet30ClientDeclareProcess extends PacketClient { private String processName; private String type; - public PacketClientDeclareProcess() { + public Packet30ClientDeclareProcess() { super((byte)0x30); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientClose.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet31ClientClose.java similarity index 81% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientClose.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet31ClientClose.java index d424a97..33c25a4 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientClose.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet31ClientClose.java @@ -3,9 +3,9 @@ package fr.pandacube.java.util.network.packet.packets.core_slave; import fr.pandacube.java.util.network.packet.PacketClient; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketClientClose extends PacketClient { +public class Packet31ClientClose extends PacketClient { - public PacketClientClose() { + public Packet31ClientClose() { super((byte)0x31); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientProcessQueryResponse.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet32ClientProcessQueryResponse.java similarity index 64% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientProcessQueryResponse.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet32ClientProcessQueryResponse.java index e2f90f5..c7421f0 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketClientProcessQueryResponse.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/Packet32ClientProcessQueryResponse.java @@ -2,16 +2,16 @@ package fr.pandacube.java.util.network.packet.packets.core_slave; import fr.pandacube.java.util.network.packet.PacketClient; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -import fr.pandacube.java.util.network.packet.packets.core_slave.PacketServerProcessQuery.QueryType; +import fr.pandacube.java.util.network.packet.packets.core_slave.PacketB4ServerProcessQuery.QueryType; -public class PacketClientProcessQueryResponse extends PacketClient { +public class Packet32ClientProcessQueryResponse extends PacketClient { private QueryType type; private int queryId; private byte[] responseData = null; - public PacketClientProcessQueryResponse() { + public Packet32ClientProcessQueryResponse() { super((byte)0x32); } @@ -35,23 +35,23 @@ public class PacketClientProcessQueryResponse extends PacketClient { } - public static PacketClientProcessQueryResponse destroyResponse(int queryId) { - PacketClientProcessQueryResponse q = new PacketClientProcessQueryResponse(); + public static Packet32ClientProcessQueryResponse destroyResponse(int queryId) { + Packet32ClientProcessQueryResponse q = new Packet32ClientProcessQueryResponse(); q.type = QueryType.DESTROY; q.queryId = queryId; return q; } - public static PacketClientProcessQueryResponse isAliveResponse(int queryId, boolean resp) { - PacketClientProcessQueryResponse q = new PacketClientProcessQueryResponse(); + public static Packet32ClientProcessQueryResponse isAliveResponse(int queryId, boolean resp) { + Packet32ClientProcessQueryResponse q = new Packet32ClientProcessQueryResponse(); q.type = QueryType.IS_ALIVE; q.queryId = queryId; q.responseData = new byte[] {(byte)(resp ? 1 : 0)}; return q; } - public static PacketClientProcessQueryResponse exitStatusResponse(int queryId, int resp) { - PacketClientProcessQueryResponse q = new PacketClientProcessQueryResponse(); + public static Packet32ClientProcessQueryResponse exitStatusResponse(int queryId, int resp) { + Packet32ClientProcessQueryResponse q = new Packet32ClientProcessQueryResponse(); q.type = QueryType.EXIT_STATUS; q.queryId = queryId; q.responseData = new ByteBuffer(4, CHARSET).putInt(resp).array(); diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerClose.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB0ServerClose.java similarity index 81% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerClose.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB0ServerClose.java index d0814d4..99a850a 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerClose.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB0ServerClose.java @@ -3,9 +3,9 @@ package fr.pandacube.java.util.network.packet.packets.core_slave; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerClose extends PacketServer { +public class PacketB0ServerClose extends PacketServer { - public PacketServerClose() { + public PacketB0ServerClose() { super((byte)0xB0); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessDeclarationConfirm.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB1ServerProcessDeclarationConfirm.java similarity index 82% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessDeclarationConfirm.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB1ServerProcessDeclarationConfirm.java index 03741c6..dc8a7a6 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessDeclarationConfirm.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB1ServerProcessDeclarationConfirm.java @@ -3,11 +3,11 @@ package fr.pandacube.java.util.network.packet.packets.core_slave; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerProcessDeclarationConfirm extends PacketServer { +public class PacketB1ServerProcessDeclarationConfirm extends PacketServer { private String serverName; - public PacketServerProcessDeclarationConfirm() { + public PacketB1ServerProcessDeclarationConfirm() { super((byte)0xB1); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerConnectSuccess.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB2ServerConnectSuccess.java similarity index 78% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerConnectSuccess.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB2ServerConnectSuccess.java index f107f27..84fa737 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerConnectSuccess.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB2ServerConnectSuccess.java @@ -3,9 +3,9 @@ package fr.pandacube.java.util.network.packet.packets.core_slave; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerConnectSuccess extends PacketServer { +public class PacketB2ServerConnectSuccess extends PacketServer { - public PacketServerConnectSuccess() { + public PacketB2ServerConnectSuccess() { super((byte)0xB2); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessInput.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB3ServerProcessInput.java similarity index 89% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessInput.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB3ServerProcessInput.java index dec06d6..000cb65 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessInput.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB3ServerProcessInput.java @@ -3,12 +3,12 @@ package fr.pandacube.java.util.network.packet.packets.core_slave; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerProcessInput extends PacketServer { +public class PacketB3ServerProcessInput extends PacketServer { private String serverName; private byte[] dataToSend; - public PacketServerProcessInput() { + public PacketB3ServerProcessInput() { super((byte)0xB3); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessQuery.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB4ServerProcessQuery.java similarity index 67% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessQuery.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB4ServerProcessQuery.java index 2fbfac0..f1538d1 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketServerProcessQuery.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/core_slave/PacketB4ServerProcessQuery.java @@ -4,7 +4,7 @@ import fr.pandacube.java.util.RandomUtil; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerProcessQuery extends PacketServer { +public class PacketB4ServerProcessQuery extends PacketServer { private String processName; private QueryType type; @@ -12,7 +12,7 @@ public class PacketServerProcessQuery extends PacketServer { private byte[] queryData = null; - public PacketServerProcessQuery() { + public PacketB4ServerProcessQuery() { super((byte)0xB4); } @@ -36,30 +36,30 @@ public class PacketServerProcessQuery extends PacketServer { } - public static PacketServerProcessQuery startQuery(String processName) { - PacketServerProcessQuery q = new PacketServerProcessQuery(); + public static PacketB4ServerProcessQuery startQuery(String processName) { + PacketB4ServerProcessQuery q = new PacketB4ServerProcessQuery(); q.processName = processName; q.type = QueryType.START; return q; } - public static PacketServerProcessQuery destroyQuery(String processName, boolean wait) { - PacketServerProcessQuery q = new PacketServerProcessQuery(); + public static PacketB4ServerProcessQuery destroyQuery(String processName, boolean wait) { + PacketB4ServerProcessQuery q = new PacketB4ServerProcessQuery(); q.processName = processName; q.type = QueryType.DESTROY; q.queryData = new byte[] {(byte)(wait ? 1 : 0)}; return q; } - public static PacketServerProcessQuery isAliveQuery(String processName) { - PacketServerProcessQuery q = new PacketServerProcessQuery(); + public static PacketB4ServerProcessQuery isAliveQuery(String processName) { + PacketB4ServerProcessQuery q = new PacketB4ServerProcessQuery(); q.processName = processName; q.type = QueryType.IS_ALIVE; return q; } - public static PacketServerProcessQuery exitStatusQuery(String processName) { - PacketServerProcessQuery q = new PacketServerProcessQuery(); + public static PacketB4ServerProcessQuery exitStatusQuery(String processName) { + PacketB4ServerProcessQuery q = new PacketB4ServerProcessQuery(); q.processName = processName; q.type = QueryType.EXIT_STATUS; return q; diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketClientAuthenticate.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/Packet50ClientAuthenticate.java similarity index 88% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketClientAuthenticate.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/global/Packet50ClientAuthenticate.java index 55f82ed..05c822a 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketClientAuthenticate.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/Packet50ClientAuthenticate.java @@ -3,12 +3,12 @@ package fr.pandacube.java.util.network.packet.packets.global; import fr.pandacube.java.util.network.packet.PacketClient; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketClientAuthenticate extends PacketClient { +public class Packet50ClientAuthenticate extends PacketClient { private String password; private String additionalData = ""; - public PacketClientAuthenticate() { + public Packet50ClientAuthenticate() { super((byte)0x50); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketClientLogRecord.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/Packet51ClientLogRecord.java similarity index 93% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketClientLogRecord.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/global/Packet51ClientLogRecord.java index 44c52b3..9249fc3 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketClientLogRecord.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/Packet51ClientLogRecord.java @@ -3,7 +3,7 @@ package fr.pandacube.java.util.network.packet.packets.global; import fr.pandacube.java.util.network.packet.PacketClient; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketClientLogRecord extends PacketClient { +public class Packet51ClientLogRecord extends PacketClient { private long time; private String level; @@ -11,7 +11,7 @@ public class PacketClientLogRecord extends PacketClient { private String message; private String throwable; - public PacketClientLogRecord() { + public Packet51ClientLogRecord() { super((byte)0x51); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerException.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD0ServerException.java similarity index 88% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerException.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD0ServerException.java index 4c7b802..5d9c4a3 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerException.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD0ServerException.java @@ -6,11 +6,11 @@ import java.io.StringWriter; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerException extends PacketServer { +public class PacketD0ServerException extends PacketServer { private String exception; - public PacketServerException() { + public PacketD0ServerException() { super((byte)0xD0); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerCantAuthenticate.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD1ServerCantAuthenticate.java similarity index 76% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerCantAuthenticate.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD1ServerCantAuthenticate.java index 8a471ff..3dce844 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerCantAuthenticate.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD1ServerCantAuthenticate.java @@ -3,9 +3,9 @@ package fr.pandacube.java.util.network.packet.packets.global; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerCantAuthenticate extends PacketServer { +public class PacketD1ServerCantAuthenticate extends PacketServer { - public PacketServerCantAuthenticate() { + public PacketD1ServerCantAuthenticate() { super((byte)0xD1); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerCommand.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD2ServerCommand.java similarity index 87% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerCommand.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD2ServerCommand.java index f74f888..5a93a1b 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketServerCommand.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/global/PacketD2ServerCommand.java @@ -3,13 +3,13 @@ package fr.pandacube.java.util.network.packet.packets.global; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerCommand extends PacketServer { +public class PacketD2ServerCommand extends PacketServer { private String command; private boolean async; private boolean returnResult; - public PacketServerCommand() { + public PacketD2ServerCommand() { super((byte)0xD2); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/web/PacketClientWebRequest.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/web/Packet00ClientWebRequest.java similarity index 89% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/web/PacketClientWebRequest.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/web/Packet00ClientWebRequest.java index 5a1a174..976205e 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/web/PacketClientWebRequest.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/web/Packet00ClientWebRequest.java @@ -3,12 +3,12 @@ package fr.pandacube.java.util.network.packet.packets.web; import fr.pandacube.java.util.network.packet.PacketClient; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketClientWebRequest extends PacketClient { +public class Packet00ClientWebRequest extends PacketClient { private String password; private String jsonData; - public PacketClientWebRequest() { + public Packet00ClientWebRequest() { super((byte)0x00); } diff --git a/src/main/java/fr/pandacube/java/util/network/packet/packets/web/PacketServerWebResponse.java b/src/main/java/fr/pandacube/java/util/network/packet/packets/web/Packet80ServerWebResponse.java similarity index 85% rename from src/main/java/fr/pandacube/java/util/network/packet/packets/web/PacketServerWebResponse.java rename to src/main/java/fr/pandacube/java/util/network/packet/packets/web/Packet80ServerWebResponse.java index b15c977..bc3b6a4 100644 --- a/src/main/java/fr/pandacube/java/util/network/packet/packets/web/PacketServerWebResponse.java +++ b/src/main/java/fr/pandacube/java/util/network/packet/packets/web/Packet80ServerWebResponse.java @@ -3,11 +3,11 @@ package fr.pandacube.java.util.network.packet.packets.web; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -public class PacketServerWebResponse extends PacketServer { +public class Packet80ServerWebResponse extends PacketServer { private String jsonData; - public PacketServerWebResponse() { + public Packet80ServerWebResponse() { super((byte)0x80); } diff --git a/src/main/java/fr/pandacube/java/util/network/server/TCPServer.java b/src/main/java/fr/pandacube/java/util/network/server/TCPServer.java index 3ad8bb8..bbce74b 100644 --- a/src/main/java/fr/pandacube/java/util/network/server/TCPServer.java +++ b/src/main/java/fr/pandacube/java/util/network/server/TCPServer.java @@ -32,7 +32,7 @@ import fr.pandacube.java.util.network.packet.PacketException; import fr.pandacube.java.util.network.packet.PacketServer; import fr.pandacube.java.util.network.packet.ResponseCallback; import fr.pandacube.java.util.network.packet.bytebuffer.ByteBuffer; -import fr.pandacube.java.util.network.packet.packets.global.PacketServerException; +import fr.pandacube.java.util.network.packet.packets.global.PacketD0ServerException; import org.javatuples.Pair; /** @@ -158,7 +158,7 @@ public class TCPServer extends Thread implements Closeable { } catch (Exception e) { Log.severe("Exception while handling packet. This exception will be sent to the client with PacketServerException packet.", e); - PacketServerException packet = new PacketServerException(); + PacketD0ServerException packet = new PacketD0ServerException(); packet.setException(e); send(packet); }