Files
PemukulPaku/GameServer/Handlers/EnterWorldChatroomReqHandler.cs
rafi1212122 eb4d375ccd 🤯 chatters
2023-06-01 07:58:46 +07:00

28 lines
1.1 KiB
C#

using Common.Resources.Proto;
using PemukulPaku.GameServer.Game.Chatrooms;
namespace PemukulPaku.GameServer.Handlers
{
[PacketCmdId(CmdId.EnterWorldChatroomReq)]
internal class EnterWorldChatroomReqHandler : IPacketHandler
{
public void Handle(Session session, Packet packet)
{
EnterWorldChatroomReq Data = packet.GetDecodedBody<EnterWorldChatroomReq>();
WorldChatroom.GetInstance().Left(session);
Chatroom JoinedChatroom = WorldChatroom.GetInstance().Join(session, Data.ChatroomId == 0 ? 1 : Data.ChatroomId);
EnterWorldChatroomRsp Rsp = new()
{
retcode = EnterWorldChatroomRsp.Retcode.Succ,
ChatroomId = JoinedChatroom.Id,
ActivityType = ActivityWorldChatroomType.ActivityWorldChatroomTypeNone,
PlayerNum = (uint)JoinedChatroom.Members.Count
};
Rsp.HisChatMsgLists.AddRange(JoinedChatroom.Messages.Skip(JoinedChatroom.Messages.Count - 5).ToList());
session.Send(Packet.FromProto(Rsp, CmdId.EnterWorldChatroomRsp));
}
}
}