public static FriendOnline ( List |
||
users | List |
|
friend | Aura.Msgr.Database.User | |
return | void |
public void FriendUnblock(MsgrClient client, Packet packet) { var contactId = packet.GetInt(); // Check friend var friend = client.User.GetFriend(contactId); if (friend == null) { Log.Warning("FriendUnblock: User '{0}' tried to block invalid friend.", client.User.AccountId); return; } // Check status if (friend.FriendshipStatus != FriendshipStatus.Blocked) { Send.FriendUnblockR(client.User, false, contactId); return; } // Change status friend.FriendshipStatus = FriendshipStatus.Normal; MsgrServer.Instance.Database.SetFriendshipStatusOneSided(client.User.Id, contactId, friend.FriendshipStatus); Send.FriendUnblockR(client.User, true, contactId); // Live update var friendUser = MsgrServer.Instance.UserManager.Get(contactId); if (friendUser != null) { Send.FriendOnline(friendUser, client.User); } }
public void FriendListRequest(MsgrClient client, Packet packet) { var user = client.User; // Lists are sorted alphabetically by the client var groups = MsgrServer.Instance.Database.GetGroups(user); var friends = MsgrServer.Instance.Database.GetFriends(user); user.Groups.Clear(); foreach (var group in groups) { user.Groups.Add(group.Id); } user.Friends.Clear(); user.Friends.AddRange(friends); Send.GroupList(client, groups); Send.FriendListRequestR(client, friends); // Notify friends about user going online var friendUsers = MsgrServer.Instance.UserManager.Get(user.GetNormalFriendIds()); if (friendUsers.Count != 0) { Send.FriendOnline(friendUsers, user); } // Notify user about online friends friendUsers = MsgrServer.Instance.UserManager.Get(user.GetFriendIds()); foreach (var friendUser in friendUsers.Where(a => a.GetFriendshipStatus(user.Id) == FriendshipStatus.Normal)) { Send.FriendOnline(client.User, friendUser); } }
public void FriendReply(MsgrClient client, Packet packet) { var contactId = packet.GetInt(); var accepted = packet.GetBool(); // Check friend var friend = client.User.GetFriend(contactId); if (friend == null) { Log.Warning("FriendReply: User '{0}' tried to accept non-existent invitation.", client.User.AccountId); client.Kill(); // Out of sync, close connection. return; } // Check relation if (friend.FriendshipStatus != FriendshipStatus.Invited) { // Don't log, could be sent twice due to lag. return; } // Accept or remove friend if (accepted) { friend.FriendshipStatus = FriendshipStatus.Normal; MsgrServer.Instance.Database.SetFriendshipStatus(client.User.Id, contactId, friend.FriendshipStatus); // Notify user and friend if friend is online var friendUser = MsgrServer.Instance.UserManager.Get(contactId); if (friendUser != null) { friendUser.SetFriendshipStatus(client.User.Id, friend.FriendshipStatus); Send.FriendOnline(client.User, friendUser); Send.FriendOnline(friendUser, client.User); } } else { client.User.Friends.Remove(friend); MsgrServer.Instance.Database.DeleteFriend(client.User.Id, contactId); // TODO: Live update for friend? } }
public void FriendListRequest(MsgrClient client, Packet packet) { var user = client.User; // Lists are sorted alphabetically by the client var groups = MsgrServer.Instance.Database.GetGroups(user); var friends = MsgrServer.Instance.Database.GetFriends(user); user.Groups.Clear(); foreach (var group in groups) { user.Groups.Add(group.Id); } user.Friends.Clear(); user.Friends.AddRange(friends); Send.GroupList(client, groups); Send.FriendListRequestR(client, friends); // Notify friends about user going online var friendUsers = MsgrServer.Instance.UserManager.Get(user.GetNormalFriendIds()); if (friendUsers.Count != 0) { Send.FriendOnline(friendUsers, user); } // Notify user about online friends friendUsers = MsgrServer.Instance.UserManager.Get(user.GetFriendIds()); foreach (var friendUser in friendUsers.Where(a => a.GetFriendshipStatus(user.Id) == FriendshipStatus.Normal)) { Send.FriendOnline(client.User, friendUser); } // Notify guild members var guild = MsgrServer.Instance.GuildManager.FindGuildWithMember(user.CharacterId); if (guild != null) { var member = guild.GetMember(user.CharacterId); GuildManager.ForOnlineMembers(guild, memberUser => Send.GuildMemberState(memberUser.Client, guild, member, user, user.Status)); } }
public void ChangeOptions(MsgrClient client, Packet packet) { var nickname = packet.GetString(); var status = (ContactStatus)packet.GetByte(); var chatOptions = (ChatOptions)packet.GetUInt(); var user = client.User; // Check nickname if (nickname.Length > 50) { Log.Warning("User '{0}' tried to use a nickname that's longer than 50 characters.", user.AccountId); Send.ChangeOptionsR(client, false); return; } // Check status if (!Enum.IsDefined(typeof(ContactStatus), status)) { Log.Warning("User '{0}' tried to use an invalid or unknown status ({1}).", user.AccountId, status); Send.ChangeOptionsR(client, false); return; } // Check options if (!Enum.IsDefined(typeof(ChatOptions), chatOptions)) { Log.Warning("User '{0}' tried to use a invalid or unknown options ({1}).", user.AccountId, status); Send.ChangeOptionsR(client, false); return; } var prevStatus = user.Status; // Change options user.Nickname = nickname; user.Status = status; user.ChatOptions = chatOptions; MsgrServer.Instance.Database.SaveOptions(user); Send.ChangeOptionsR(client, true); // Update friends var friendUsers = MsgrServer.Instance.UserManager.Get(user.GetNormalFriendIds()); if (friendUsers.Count == 0) { return; } // Set offline if prev was not offline, set online if prev was offline, // and just update the options if not offline. if (prevStatus != ContactStatus.Offline && status == ContactStatus.Offline) { Send.FriendOffline(friendUsers, user); } else if (prevStatus == ContactStatus.Offline && status != ContactStatus.Offline) { Send.FriendOnline(friendUsers, user); } else if (status != ContactStatus.Offline) { Send.FriendOptionChanged(friendUsers, user); } }