diff --git a/libprotocol/pom.xml b/libprotocol/pom.xml
new file mode 100644
index 0000000..fbe361c
--- /dev/null
+++ b/libprotocol/pom.xml
@@ -0,0 +1,55 @@
+
+
+ 4.0.0
+ ASys Library: Protocol
+
+
+
+ DmitriyMX
+ mail@dmiriymx.ru
+
+
+
+
+ UTF-8
+ 1.8
+ 4.0.33.Final
+
+
+ asys.lib
+ protocol
+ 0.3
+ jar
+
+
+
+ io.netty
+ netty-buffer
+ ${netty.version}
+
+
+ io.netty
+ netty-handler
+ ${netty.version}
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.5.1
+
+ ${java.version}
+ ${java.version}
+ ${project.build.sourceEncoding}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/libprotocol/src/main/java/asys/lib/protocol/Packet.java b/libprotocol/src/main/java/asys/lib/protocol/Packet.java
new file mode 100644
index 0000000..3d3b17f
--- /dev/null
+++ b/libprotocol/src/main/java/asys/lib/protocol/Packet.java
@@ -0,0 +1,36 @@
+/*
+ * DmitriyMX
+ * 2016-08-25
+ */
+package asys.lib.protocol;
+
+import io.netty.buffer.ByteBuf;
+
+import java.nio.charset.Charset;
+
+public abstract class Packet {
+ protected static final int MAGIC_NUMBER = 980986;
+ private static Charset charsetUtf8 = Charset.forName("UTF-8");
+
+ protected String readString(ByteBuf in) {
+ int length = in.readInt();
+ if (length <= 0) return "";
+
+ byte[] buff = new byte[length];
+ in.readBytes(buff, 0, length);
+ return new String(buff, charsetUtf8);
+ }
+
+ protected void writeString(ByteBuf out, String string) {
+ int length = string.length();
+ if (length <= 0) {
+ out.writeInt(0);
+ } else {
+ out.writeInt(length);
+ out.writeBytes(string.getBytes(charsetUtf8));
+ }
+ }
+
+ public abstract void selfRead(ByteBuf in);
+ public abstract void selfWrite(ByteBuf out);
+}
diff --git a/libprotocol/src/main/java/asys/lib/protocol/PacketDecoder.java b/libprotocol/src/main/java/asys/lib/protocol/PacketDecoder.java
new file mode 100644
index 0000000..7ea0de4
--- /dev/null
+++ b/libprotocol/src/main/java/asys/lib/protocol/PacketDecoder.java
@@ -0,0 +1,27 @@
+/*
+ * DmitriyMX
+ * 2016-08-25
+ */
+package asys.lib.protocol;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.util.List;
+
+public class PacketDecoder extends ByteToMessageDecoder {
+ @Override
+ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List