A client known to several servers is listed once (task 12.12).
Snapcast clients keep an entry on every server they ever connected to, so the phone (one client id for all servers) or a Raspberry Pi that moved shows up as an offline leftover on the old server next to its live entry on the new one. This is a filter over the statuses of all known servers, a view for the lists; nothing is changed or removed on a server, and the group keys stay.
The rule (one client id at a time):
-
the id is on one server only: shown there;
-
connected on a server: shown there, and not as a leftover on the others. A server whose control connection is down counts as "not connected" for this (its last status may still say "connected", which can not be true any more);
-
connected nowhere: shown on the server that saw it last (
lastSeen; a missing one is 0, the oldest); a tie goes to the first server of the known order, the order of the list given to of;
-
connected on two or more servers at once (it should not happen: a client has one connection): shown on all of them, nothing is hidden among live entries; offline copies on yet other servers are hidden.
The phone is one client (task 12.19): with of(List, SnapcastOwnIds) the old per-server ids of this install count as the current id. The phone is shown once (connected wins, else the last seen, a tie goes to the current id), and every other copy of it, also one on the SAME server, is hidden; so the card of an old entry that was alone in its group is gone, and the others keep their title from their first shown member. Entries of other installs are ordinary clients.
Display only. visible(ServerKey, SnapcastGroup) and visible(ServerKey,
SnapcastServerStatus) give what the lists show: the card (title from the first shown member), the member rows, the counts "x of
y connected", the link picker. A group whose members are all hidden gives null (no card; a group that never had a member is kept). The control code must keep working on the full status of a fresh read: Group.SetClients takes the whole list of members, so a hidden member has to be in it, or the change would drop it from the group. Nothing here is used by that code.
Pure Java, immutable. Where nothing is hidden the very same objects come back.