This describes how friends are being managed in the game

This is sub-layout for documentation pages


1 Friends list retrieval

This describes, how the actual information about friends is sent to the client.
The system uses lazy principle for this, which means, that that data is loaded asynchronously, and system does not wait until it loads.
Here is a diagram that illustrates the key events of friends list data retrieval.

Once the cache is built up (as you can see in the diagram), if update() runs, and data is supposed to be sent, then the data is sent in PlayerSpecificPacket to that specific player.

Like this, all connected players will receive their friends list (sooner, or later)

2 Race conditions and special cases

This describes special cases that can happen, and how the system deals with them.

2.1 Friend logs in before friends list is retrieved

In this scenario, suppose we have two players, \(P1\) and \(P2\). Also suppose, that \(P1\) has \(P2\) in his friends list.
Suppose, that we do not care in this example about privacy and visibility modifiers.
Suppose following events (in order)

At this moment, 2 main cases may happen: or In the second case, the online status will be incorrectly displayed.
This scenario is extremelly difficult to reproduce, and because of the complexity of the system, I failed to prove, that it really can happen.
However, the case is dealt with anyway, because consistency and game experience is the main concern

2.1.1 Solution

To solve this, client side will just keep the login status data, and when friends list is finally received, it uses the kept data to overwrite the online status

This is sufficient and complete solution to the problem