-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathCharacterCommunityCharacterStatusGetHandler.cs
More file actions
72 lines (63 loc) · 3.13 KB
/
Copy pathCharacterCommunityCharacterStatusGetHandler.cs
File metadata and controls
72 lines (63 loc) · 3.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using Arrowgene.Ddon.Server;
using Arrowgene.Ddon.Shared.Entity.PacketStructure;
using Arrowgene.Ddon.Shared.Entity.Structure;
using Arrowgene.Ddon.Shared.Model;
using Arrowgene.Logging;
using System.Collections.Generic;
namespace Arrowgene.Ddon.GameServer.Handler
{
public class CharacterCommunityCharacterStatusGetHandler : GameRequestPacketHandler<C2SCharacterCommunityCharacterStatusGetReq, S2CCharacterCommunityCharacterStatusGetRes>
{
private static readonly ServerLogger Logger = LogProvider.Logger<ServerLogger>(typeof(CharacterCommunityCharacterStatusGetHandler));
public CharacterCommunityCharacterStatusGetHandler(DdonGameServer server) : base(server)
{
}
public override S2CCharacterCommunityCharacterStatusGetRes Handle(GameClient client, C2SCharacterCommunityCharacterStatusGetReq request)
{
List<CDataCharacterListElement> updateCharacterList = new List<CDataCharacterListElement>();
List<CDataUpdateMatchingProfileInfo> updateMatchingProfileList = new List<CDataUpdateMatchingProfileInfo>();
List<(ContactListEntity, CDataCharacterListElement)> friends = Database.SelectFullContactListByCharacterId(client.Character.CharacterId);
foreach ((ContactListEntity contact, CDataCharacterListElement character) in friends)
{
if (contact.Type != ContactListType.FriendList || contact.Status != ContactListStatus.Accepted)
{
continue;
}
var matchClient = Server.ClientLookup.GetClientByCharacterId(character.CommunityCharacterBaseInfo.CharacterId);
if (matchClient != null)
{
character.OnlineStatus = matchClient.Character?.OnlineStatus ?? OnlineStatus.Offline;
character.ServerId = (ushort)Server.Id;
}
else
{
var presence = Server.RpcManager.FindPlayerPresenceById(character.CommunityCharacterBaseInfo.CharacterId);
if (presence.ChannelId != 0)
{
character.OnlineStatus = presence.OnlineStatus;
character.ServerId = presence.ChannelId;
}
else
{
character.OnlineStatus = OnlineStatus.Offline;
}
}
updateCharacterList.Add(character);
updateMatchingProfileList.Add(new CDataUpdateMatchingProfileInfo()
{
CharacterId = character.CommunityCharacterBaseInfo.CharacterId,
Comment = character.MatchingProfile,
});
}
client.Send(new S2CCharacterCommunityCharacterStatusUpdateNtc()
{
UpdateCharacterList = updateCharacterList,
UpdateMatchingProfileList = updateMatchingProfileList
});
return new S2CCharacterCommunityCharacterStatusGetRes()
{
Result = (uint)(updateCharacterList.Count + 1) // ???
};
}
}
}