diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/BinaryStream.java b/mirai-core/src/main/java/net/mamoe/mirai/network/BinaryStream.java new file mode 100644 index 000000000..ed862b37b --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/BinaryStream.java @@ -0,0 +1,8 @@ +package net.mamoe.mirai.network; + +/** + * @author Him188moe @ Mirai Project + */ +public class BinaryStream { + +} diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/Packet.java b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/Packet.java new file mode 100644 index 000000000..8c6fec9cb --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/Packet.java @@ -0,0 +1,8 @@ +package net.mamoe.mirai.network.packet; + +/** + * @author Him188moe @ Mirai Project + */ +public interface Packet { + +} diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketId.java b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketId.java new file mode 100644 index 000000000..c0d6ef6a9 --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/PacketId.java @@ -0,0 +1,11 @@ +package net.mamoe.mirai.network.packet; + +/** + * @author Him188moe @ Mirai Project + */ +public @interface PacketId { + /** + * 获取用于识别的包 ID + */ + int value(); +} diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientLoginPacket.java b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientLoginPacket.java new file mode 100644 index 000000000..c15fbfb6b --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientLoginPacket.java @@ -0,0 +1,14 @@ +package net.mamoe.mirai.network.packet.client; + +import net.mamoe.mirai.network.packet.PacketId; + +/** + * @author Him188moe @ Mirai Project + */ +@PacketId(5) +public class ClientLoginPacket extends ClientPacket { + @Override + public void encode() { + + } +} diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.java b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.java new file mode 100644 index 000000000..700d4990f --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/client/ClientPacket.java @@ -0,0 +1,24 @@ +package net.mamoe.mirai.network.packet.client; + +import net.mamoe.mirai.network.packet.Packet; + +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; + +/** + * @author Him188moe @ Mirai Project + */ +public abstract class ClientPacket extends DataOutputStream implements Packet { + public ClientPacket() { + super(new ByteArrayOutputStream()); + } + + public long readQQ() { + + } + + /** + * Encode this packet + */ + public abstract void encode(); +} diff --git a/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.java b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.java new file mode 100644 index 000000000..fb6470e5b --- /dev/null +++ b/mirai-core/src/main/java/net/mamoe/mirai/network/packet/server/ServerPacket.java @@ -0,0 +1,23 @@ +package net.mamoe.mirai.network.packet.server; + +import net.mamoe.mirai.network.packet.Packet; +import org.jetbrains.annotations.NotNull; + +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.InputStream; + +/** + * @author Him188moe @ Mirai Project + */ +public abstract class ServerPacket extends DataInputStream implements Packet { + public ServerPacket(@NotNull InputStream in) { + super(in); + } + + public ServerPacket(@NotNull byte[] in) { + this(new ByteArrayInputStream(in)); + } + + public abstract void decode(); +}