mirror of
https://github.com/Melledy/Nebula.git
synced 2026-11-04 21:36:51 +01:00
Implement friends list
This commit is contained in:
1 parent
1c52ec011f
commit
ecc2ef2315
15 files changed
+666
-10
No files matched your search
@@ -0,0 +1,35 @@
|
||||
package emu.nebula.server.handlers;
|
||||
|
||||
import emu.nebula.net.NetHandler;
|
||||
import emu.nebula.net.NetMsgId;
|
||||
import emu.nebula.proto.FriendUidSearch.FriendUIdSearchReq;
|
||||
import emu.nebula.proto.FriendUidSearch.FriendUIdSearchResp;
|
||||
import emu.nebula.net.HandlerId;
|
||||
import emu.nebula.Nebula;
|
||||
import emu.nebula.net.GameSession;
|
||||
|
||||
@HandlerId(NetMsgId.friend_uid_search_req)
|
||||
public class HandlerFriendUidSearchReq extends NetHandler {
|
||||
|
||||
@Override
|
||||
public byte[] handle(GameSession session, byte[] message) throws Exception {
|
||||
// Parse request
|
||||
var req = FriendUIdSearchReq.parseFrom(message);
|
||||
int uid = (int) req.getId();
|
||||
|
||||
// Get target player
|
||||
var target = Nebula.getGameContext().getPlayerModule().getPlayer(uid);
|
||||
|
||||
if (target == null) {
|
||||
return session.encodeMsg(NetMsgId.friend_uid_search_failed_ack);
|
||||
}
|
||||
|
||||
// Build response
|
||||
var rsp = FriendUIdSearchResp.newInstance()
|
||||
.setFriend(target.getFriendProto());
|
||||
|
||||
// Encode and send
|
||||
return session.encodeMsg(NetMsgId.friend_uid_search_succeed_ack, rsp);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user