Update mail state on ping

This commit is contained in:
Melledy
2025-10-30 08:28:40 -07:00
parent 7c5c0e21b7
commit 3a44ebbdc3
4 changed files with 90 additions and 39 deletions

View File

@@ -2,7 +2,9 @@ package emu.nebula.server.handlers;
import emu.nebula.net.NetHandler;
import emu.nebula.net.NetMsgId;
import emu.nebula.net.PacketHelper;
import emu.nebula.proto.PlayerPing.Pong;
import emu.nebula.proto.Public.MailState;
import emu.nebula.net.HandlerId;
import emu.nebula.Nebula;
import emu.nebula.net.GameSession;
@@ -12,9 +14,24 @@ public class HandlerPlayerPingReq extends NetHandler {
@Override
public byte[] handle(GameSession session, byte[] message) throws Exception {
// Create response
var rsp = Pong.newInstance()
.setServerTs(Nebula.getCurrentTime());
// Update mail state flag
if (session.getPlayer().getMailbox().isNewState()) {
// Clear
session.getPlayer().getMailbox().clearNewState();
// Send mail state notify
byte[] nextPackage = PacketHelper.encodeMsg(
NetMsgId.mail_state_notify,
MailState.newInstance().setNew(true)
);
rsp.setNextPackage(nextPackage);
}
return this.encodeMsg(NetMsgId.player_ping_succeed_ack, rsp);
}