mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-25 23:10:12 +08:00
update
This commit is contained in:
parent
9e21ebcb6f
commit
43595db045
@ -1,16 +1,28 @@
|
|||||||
package net.mamoe.mirai.network.packet.client;
|
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.network.packet.PacketId;
|
||||||
|
import net.mamoe.mirai.util.TEAEncryption;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Him188moe @ Mirai Project
|
* @author Him188moe @ Mirai Project
|
||||||
*/
|
*/
|
||||||
@PacketId(0x0058)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@PacketId(0x00_58)
|
||||||
public class ClientHeartbeatPacket extends ClientPacket {
|
public class ClientHeartbeatPacket extends ClientPacket {
|
||||||
|
public long qq;
|
||||||
|
public byte[] sessionKey;//登录后获得
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void encode() throws IOException {
|
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();
|
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 {
|
protected void writeQQ(long qq) throws IOException {
|
||||||
this.writeLong(qq);
|
this.writeLong(qq);
|
||||||
}
|
}
|
||||||
@ -60,9 +66,9 @@ public abstract class ClientPacket extends DataOutputStream implements Packet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode this packet.
|
* Encode this packet.
|
||||||
*
|
* <p>
|
||||||
* Before sending the packet, an {@linkplain Protocol#tail tail} will be added.
|
* Before sending the packet, an {@linkplain Protocol#tail tail} will be added.
|
||||||
*/
|
*/// TODO: 2019/8/9 添加 tail
|
||||||
public abstract void encode() throws IOException;
|
public abstract void encode() throws IOException;
|
||||||
|
|
||||||
public byte[] toByteArray() {
|
public byte[] toByteArray() {
|
||||||
|
Loading…
Reference in New Issue
Block a user