Commit 43595db0 authored by Him188moe's avatar Him188moe

update

parent 9e21ebcb
package net.mamoe.mirai.network.packet.client;
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.mamoe.mirai.network.Protocol;
import net.mamoe.mirai.network.packet.PacketId;
import net.mamoe.mirai.util.TEAEncryption;
import java.io.IOException;
/**
* @author Him188moe @ Mirai Project
*/
@PacketId(0x0058)
@EqualsAndHashCode(callSuper = true)
@Data
@PacketId(0x00_58)
public class ClientHeartbeatPacket extends ClientPacket {
public long qq;
public byte[] sessionKey;//登录后获得
@Override
public void encode() throws IOException {
this.writeRandom(2);
this.writeQQ(qq);
this.writeHex(Protocol.fixVer);
this.write(TEAEncryption.encrypt(new byte[]{0x00, 0x01, 0x00, 0x01}, sessionKey));
}
}
......@@ -39,6 +39,6 @@ public class ClientLoginPacket extends ClientPacket {
};
data.encode();
TEAEncryption.encrypt(data.toByteArray(), Protocol.hexToBytes(Protocol._0825key));
this.write(TEAEncryption.encrypt(data.toByteArray(), Protocol.hexToBytes(Protocol._0825key)));
}
}
......@@ -53,6 +53,12 @@ public abstract class ClientPacket extends DataOutputStream implements Packet {
}
}
protected void writeRandom(int length) throws IOException {
for (int i = 0; i < length; i++) {
this.writeByte((byte) (int) (Math.random() * 255));
}
}
protected void writeQQ(long qq) throws IOException {
this.writeLong(qq);
}
......@@ -60,9 +66,9 @@ public abstract class ClientPacket extends DataOutputStream implements Packet {
/**
* Encode this packet.
*
* <p>
* Before sending the packet, an {@linkplain Protocol#tail tail} will be added.
*/
*/// TODO: 2019/8/9 添加 tail
public abstract void encode() throws IOException;
public byte[] toByteArray() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment