So I have a game server that has 50-200 players online at a time. Everyone are able to change their usernames every 30 days. Where i'm running into issue is i'm not exactly sure how to deal with username change on that user's friend list. I'm allowing everyone to add 200 friends, and friends list contains userID (unique for everyone) and userName. For example when a user changes name, and has 200 friends, and only 2 of 200 friends are online, how would i change username on the offline users, so whenever they login, they see that user's new name. Ways i thought about:
- Loop thru friends list and make changes in ever friend's database whenever u change name
- When user logins and logoffs, friend list is looped and usernames are selected from db
- Whenever someone opens a friend list, re-select all friends's usernames from db
When user has 200 friends, i'm pretty sure all of those ways are going to consume too many resources and cause delays in the server. But i'm not sure what's the best way to even do it. And there's one more thing, name changes doesn't always happen when u change name, they happen when u get higher or lower role too, so there may be alot of name changes at some point. What would be the best way to handle it?
public class PlayerFriend
{
[ProtoMember(1)]
public ulong userID { get; set; }
[ProtoMember(2)]
public string displayName { get; set; }
}
public class PlayerData
{
[ProtoMember(34)]
public Dictionary<ulong, PlayerFriend> friends = new Dictionary<ulong, PlayerFriend>();
}