mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-15 13:54:51 +01:00
Refactor how handlers encode messages
This commit is contained in:
@@ -14,6 +14,8 @@ import emu.nebula.game.player.Player;
|
||||
import emu.nebula.util.AeadHelper;
|
||||
import emu.nebula.util.Utils;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import us.hebi.quickbuf.ProtoMessage;
|
||||
import us.hebi.quickbuf.RepeatedByte;
|
||||
|
||||
@Getter
|
||||
@@ -63,6 +65,8 @@ public class GameSession {
|
||||
public boolean hasPlayer() {
|
||||
return this.player != null;
|
||||
}
|
||||
|
||||
// Encryption
|
||||
|
||||
public void setClientKey(RepeatedByte key) {
|
||||
this.clientPublicKey = key.toArray();
|
||||
@@ -95,6 +99,8 @@ public class GameSession {
|
||||
return this.token;
|
||||
}
|
||||
|
||||
// Login
|
||||
|
||||
public boolean login(String loginToken) {
|
||||
// Sanity check
|
||||
if (this.account != null) {
|
||||
@@ -128,4 +134,19 @@ public class GameSession {
|
||||
public void updateLastActiveTime() {
|
||||
this.lastActiveTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
// Packet encoding helper functions
|
||||
|
||||
public byte[] encodeMsg(int msgId, byte[] packet) {
|
||||
return PacketHelper.encodeMsg(msgId, packet);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public byte[] encodeMsg(int msgId, ProtoMessage<?> proto) {
|
||||
return PacketHelper.encodeMsg(msgId, proto);
|
||||
}
|
||||
|
||||
public byte[] encodeMsg(int msgId) {
|
||||
return PacketHelper.encodeMsg(msgId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user