mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-22 15:43:49 +01:00
The userBinary and minidata maps with their locks were spread across Server as raw fields with manual lock management. Cross-channel session searches also required acquiring nested locks (server lock + binary lock). Encapsulating in dedicated types eliminates the nested locking and reduces Server's field count by 4.
39 lines
1023 B
Go
39 lines
1023 B
Go
package channelserver
|
|
|
|
import (
|
|
"erupe-ce/network/mhfpacket"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func handleMsgSysInsertUser(s *Session, p mhfpacket.MHFPacket) {}
|
|
|
|
func handleMsgSysDeleteUser(s *Session, p mhfpacket.MHFPacket) {}
|
|
|
|
func handleMsgSysSetUserBinary(s *Session, p mhfpacket.MHFPacket) {
|
|
pkt := p.(*mhfpacket.MsgSysSetUserBinary)
|
|
if pkt.BinaryType < 1 || pkt.BinaryType > 5 {
|
|
s.logger.Warn("Invalid BinaryType", zap.Uint8("type", pkt.BinaryType))
|
|
return
|
|
}
|
|
s.server.userBinary.Set(s.charID, pkt.BinaryType, pkt.RawDataPayload)
|
|
|
|
s.server.BroadcastMHF(&mhfpacket.MsgSysNotifyUserBinary{
|
|
CharID: s.charID,
|
|
BinaryType: pkt.BinaryType,
|
|
}, s)
|
|
}
|
|
|
|
func handleMsgSysGetUserBinary(s *Session, p mhfpacket.MHFPacket) {
|
|
pkt := p.(*mhfpacket.MsgSysGetUserBinary)
|
|
|
|
data, ok := s.server.userBinary.Get(pkt.CharID, pkt.BinaryType)
|
|
|
|
if !ok {
|
|
doAckBufFail(s, pkt.AckHandle, make([]byte, 4))
|
|
} else {
|
|
doAckBufSucceed(s, pkt.AckHandle, data)
|
|
}
|
|
}
|
|
|
|
func handleMsgSysNotifyUserBinary(s *Session, p mhfpacket.MHFPacket) {}
|