YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.snapcast.SnapcastReceivers Class Reference

The Snapcast groups as receivers: joins the SnapcastDirectory (which servers exist) with one SnapcastServerLink per server (what each server says) and hands out SnapcastGroupDevices. More...

Inheritance diagram for de.yaacc.snapcast.SnapcastReceivers:
Inheritance graph
Collaboration diagram for de.yaacc.snapcast.SnapcastReceivers:
Collaboration graph

Classes

interface  ChangeListener
 Told when the groups (or the offline state of one) may have changed; any thread, no lock held. More...
 
class  GroupState
 What one group looks like right now, for the rows and the group sheet: the group and the status of its server as of the last status that was read, whether the control connection is up, and the endpoint of the server.
 
interface  LinkFactory
 Opens the link to a server (not started yet); SnapcastSession in the app. More...
 
interface  OwnIdsSource
 The phone's own client ids (task 12.19): the current id and the legacy per-server ids of this install, for the servers that are known now. More...
 

Public Member Functions

 SnapcastReceivers (SnapcastDirectory directory, LinkFactory factory, RetryScheduler scheduler, Supplier< SnapcastGroupDevice.Labels > labels, long closeGraceMillis)
 
 SnapcastReceivers (SnapcastDirectory directory, LinkFactory factory, RetryScheduler scheduler, Supplier< SnapcastGroupDevice.Labels > labels, long closeGraceMillis, MonotonicClock clock)
 
void setOwnIdsSource (OwnIdsSource source)
 Where the phone's own client ids come from; without one nothing of the phone is merged (null clears it).
 
SnapcastOwnIds ownIds ()
 The phone's own client ids for the servers that are listed now: the current id and this install's legacy ids.
 
void addChangeListener (ChangeListener listener)
 
void removeChangeListener (ChangeListener listener)
 
void pageStarted ()
 A page that shows receivers became visible: connect to the listed servers (and retry the ones that are down).
 
void pageStopped ()
 A page was hidden; with the last one gone the links close after the grace.
 
void retain (ServerKey key)
 Keeps the link to a listed server open without a page (a player that feeds it); see release.
 
void release (ServerKey key)
 
void wake (Collection< String > receiverIds)
 Selected receivers are missing: connect to the listed servers that hold the Snapcast ones among receiverIds (and to no other), so that their groups are known soon.
 
void wakeServer (ServerKey key)
 Connects to one listed server without a page and without a player (the renderer's group chooser reads its groups with it, see groupsOf); the link closes by itself after the grace period.
 
List< SnapcastGroupDevice > groupsOf (ServerKey key)
 The groups of one server as of its last status, sorted by name.
 
void shutdown ()
 Closes every link and forgets everything.
 
SnapcastServerLink getLink (ServerKey key)
 The link of a server while it is open; null otherwise.
 
List< SnapcastGroupDevice > groups ()
 The groups of the servers that are listed, as of the last status of each server.
 
List< String > describe (ServerKey key)
 What this server said and why each of its groups is listed or not, for the discovery report: one line for the link and the last status, one line for each group with its clients.
 
SnapcastGroupDevice findGroup (String receiverId)
 
GroupState stateOf (String receiverId)
 The state of a group by its receiver id.
 
boolean isPending (String receiverId)
 True for the id of a group whose server is listed but has not delivered its status yet (a cold start, or a connection that is still coming up): the group is not known, but it is not gone either.
 
void selectionChanged (Collection< String > receiverIds)
 The selection is kept by SnapcastSelectedServers (the hub); the receivers have nothing to remember.
 
- Public Member Functions inherited from de.yaacc.snapcast.SnapcastGroupSource

Static Public Member Functions

static SnapcastRendererOutput.GroupFacts factsOf (GroupState state)
 What a state says about the group, for the renderer's output (SnapcastRendererOutput): null (no such server in the list, or a malformed id) is NOT_LISTED.
 

Static Public Attributes

static final int MAX_GROUPS = 64
 The most groups listed (the receiver rows watch at most 64 receivers).
 
static final long OFFLINE_CLIENT_GRACE_MILLIS = 60_000L
 How long a group stays listed after its last client went offline: a client that reconnects (a stream that was dropped, a restart of the app) is gone for a moment, and the row must not blink in and out of the list meanwhile.
 

Additional Inherited Members

- Public Attributes inherited from de.yaacc.snapcast.SnapcastGroupSource
SnapcastGroupSource NONE
 No groups; the default of a client that has no hub.
 

Detailed Description

The Snapcast groups as receivers: joins the SnapcastDirectory (which servers exist) with one SnapcastServerLink per server (what each server says) and hands out SnapcastGroupDevices.

Pure Java; the link factory, the scheduler and the labels (asked for each time they are needed, so a change of the language shows) are injected.

  • Lazy connections. A link is opened only for a server that is listed in the directory and only while a page is visible (pageStarted), the server is retained (a player uses it), or a selected receiver of it is woken. Nothing connects to a server that is not listed, and the directory holds only addresses that passed the range filter or that the user typed in.
  • Grace. When the last page is hidden the links close after closeGraceMillis (so that switching between the tab and the sheet does not reconnect), except retained ones. A server that leaves the directory (removed in the settings, discovery switched off, its grace over) has its link closed even when it is retained: the close tells the link's listeners, so a feed that runs to it ends (SnapcastSession#close).
  • Last known state. The last status of a server is kept when its link is closed or down, and its groups stay listed marked as offline, so a stored selection survives a hidden page. A server that leaves the directory (its grace is over; a manual server never leaves) takes its groups with it; a group that is no longer in a fresh status disappears. At most {@value MAX_GROUPS} groups are listed.

Thread safe; no lock is held while a link or a listener is called. The list of servers is read under the lock (a quiet snapshot; the sweep of the expired ones happens before, outside the lock), so a server that left is never reconciled from an out-of-date list.

Identity. groups() and findGroup return the same SnapcastGroupDevice instance for a group for as long as its name, offline flag, stream and number of members stay the same (the lists compare devices by identity); a changed group gets a new instance, a vanished one is forgotten. A stored selection of a group whose server is listed but has not answered yet is pending.

Member Function Documentation

◆ describe()

List< String > de.yaacc.snapcast.SnapcastReceivers.describe ( ServerKey key)

What this server said and why each of its groups is listed or not, for the discovery report: one line for the link and the last status, one line for each group with its clients.

Nothing is read from the network.

Here is the call graph for this function:

◆ findGroup()

SnapcastGroupDevice de.yaacc.snapcast.SnapcastReceivers.findGroup ( String receiverId)
Returns
the group with this receiver id (snapcast:...), or null if it is not known (any more)

Implements de.yaacc.snapcast.SnapcastGroupSource.

Referenced by de.yaacc.snapcast.SnapcastHub.findGroup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLink()

SnapcastServerLink de.yaacc.snapcast.SnapcastReceivers.getLink ( ServerKey key)

The link of a server while it is open; null otherwise.

For the code that controls the server (the player).

◆ groups()

List< SnapcastGroupDevice > de.yaacc.snapcast.SnapcastReceivers.groups ( )

The groups of the servers that are listed, as of the last status of each server.

Cheap: no network.

Implements de.yaacc.snapcast.SnapcastGroupSource.

Referenced by de.yaacc.snapcast.SnapcastHub.groups(), and de.yaacc.snapcast.SnapcastReceivers.groupsOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ groupsOf()

List< SnapcastGroupDevice > de.yaacc.snapcast.SnapcastReceivers.groupsOf ( ServerKey key)

The groups of one server as of its last status, sorted by name.

Returns
null while the server is not listed or has not delivered a status (the caller waits and asks again); an empty list for a server that answered without groups
Here is the call graph for this function:

◆ isPending()

boolean de.yaacc.snapcast.SnapcastReceivers.isPending ( String receiverId)

True for the id of a group whose server is listed but has not delivered its status yet (a cold start, or a connection that is still coming up): the group is not known, but it is not gone either.

The caller keeps such an id in a stored selection instead of dropping it. False for a group that is known, for a server that is not listed (any more), for a server that answered without the group, and for anything that is not a group id.

Implements de.yaacc.snapcast.SnapcastGroupSource.

Referenced by de.yaacc.snapcast.SnapcastHub.isPending().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ownIds()

SnapcastOwnIds de.yaacc.snapcast.SnapcastReceivers.ownIds ( )

The phone's own client ids for the servers that are listed now: the current id and this install's legacy ids.

For the code that labels the phone's row and decides the cleanup of old entries; none when the install has no secret.

◆ selectionChanged()

void de.yaacc.snapcast.SnapcastReceivers.selectionChanged ( Collection< String > receiverIds)

The selection is kept by SnapcastSelectedServers (the hub); the receivers have nothing to remember.

Implements de.yaacc.snapcast.SnapcastGroupSource.

◆ stateOf()

GroupState de.yaacc.snapcast.SnapcastReceivers.stateOf ( String receiverId)

The state of a group by its receiver id.

Returns
the state; null when the id is no well-formed group id, or its server is not listed (any more)
Here is the call graph for this function:

◆ wake()

void de.yaacc.snapcast.SnapcastReceivers.wake ( Collection< String > receiverIds)

Selected receivers are missing: connect to the listed servers that hold the Snapcast ones among receiverIds (and to no other), so that their groups are known soon.

Does not block.

Implements de.yaacc.snapcast.SnapcastGroupSource.

Referenced by de.yaacc.snapcast.SnapcastHub.wake().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ wakeServer()

void de.yaacc.snapcast.SnapcastReceivers.wakeServer ( ServerKey key)

Connects to one listed server without a page and without a player (the renderer's group chooser reads its groups with it, see groupsOf); the link closes by itself after the grace period.

Nothing for a server that is not listed.


The documentation for this class was generated from the following file: